YouTube Video WindowOpner

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

目前為 2022-10-23 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         YouTube Video WindowOpner
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  YouTube動画・配信を別ウィンドウで開くアイコンを設置
// @author       You
// @include        https://www.youtube.com/watch?v=*
// @include      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}?auto`, "window_name","width=1024,height=576")
	})
}else if(location.href.match("https://www.youtube.com/embed/") && location.search == "?auto"){
		//動画を再生
		document.querySelector('#movie_player').playVideo()
}