YouTube Video WindowOpner

YouTube動画・配信を別ウィンドウで開くアイコンを設置

目前为 2022-10-23 提交的版本。查看 最新版本

// ==UserScript==
// @name         YouTube Video WindowOpner
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  YouTube動画・配信を別ウィンドウで開くアイコンを設置
// @author       You
// @match        https://www.youtube.com/watch?v=*
// @match        https://www.youtube.com/embed/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant        none
// @license MIT
// ==/UserScript==

//SVGアイコン追加
if(location.pathname == "/watch"){
	document.querySelector('[aria-label="設定"]').insertAdjacentHTML("afterend", `
<div  id="windowOpen" class="ytp-button" aria-label="別ウィンドウで開く" title="別ウィンドウで開く" data-title-no-tooltip="別ウィンドウで開く">

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" viewBox="-150 -230 975 975" style="enable-background:new 0 0 600 600;" xml:space="preserve">
<style type="text/css">
	.st0{fill:#FFF;}
</style>
<g id="XMLID_6_">
	<path id="XMLID_11_" class="st0" d="M418.5,139.4H232.4v139.8h186.1V139.4z M464.8,46.7H46.3C20.5,46.7,0,68.1,0,93.1v325.9   c0,25.8,21.4,46.3,46.3,46.3h419.4c25.8,0,46.3-20.5,46.3-46.3V93.1C512,67.2,490.6,46.7,464.8,46.7z M464.8,418.9H46.3V92.2h419.4   v326.8H464.8z"></path>
</g>
</svg>

</div>`)

	//イベント作成
	document.getElementById("windowOpen").addEventListener("click", e => {

		//動画を止める
		document.querySelector('#movie_player').pauseVideo()
		//別ウィンドウを作成
		const VIDEO_ID = document.querySelector('#movie_player').getVideoStats().debug_videoId
		window.open(`https://www.youtube.com/embed/${VIDEO_ID}`, "window_name","width=1024,height=576")
	})
}else if(location.href.match("https://www.youtube.com/embed/")){
		//動画を再生
		document.querySelector('#movie_player').playVideo()
}