您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Enabled PiP on twitch.tv and youtube.com for macOS only.
// ==UserScript== // @name Twitch and YouTube PiP-Enable for Mac // @namespace https://greasyfork.runtimutd.eu.org/en/users/873652-blazingfire007 // @license MIT // @version 1.0.0 // @author Eli Richardson // @description Enabled PiP on twitch.tv and youtube.com for macOS only. // @match *://*.twitch.tv/* // @match *://*.youtube.com/* // @run-at document-end // ==/UserScript== window.pipscript = {}; window.pipscript.control = false; window.pipscript.enabled = false; document.addEventListener('readystatechange', async function (e) { if (document.readyState === 'complete') { console.log('PiP: injecting...'); if (typeof document.querySelector === 'undefined' && typeof $ === 'undefined') { return alert('Unsupported browser!'); } if (typeof document.querySelector === 'undefined') { document.querySelector = $; } return setupListeners(); } else { return e; } }); function setupListeners() { document.addEventListener('keydown', function (e) { if (e.key === 'Control') window.control = true; }); document.addEventListener('keyup', function (e) { if (e.key === 'Control') window.control = false; else if (e.key === 'p' && window.control) { if (window.pipscript.enabled) { document.exitPictureInPicture(); window.pipscript.enabled = false; } else { document.querySelector('video').requestPictureInPicture().then(console.log); window.pipscript.enabled = true; } } }); }