您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Disabled automatic playback ("Autoplay") of YouTube videos.
当前为
// ==UserScript== // @name YouTube | Stop Autoplay (2018) // @namespace de.sidneys.userscripts // @homepage https://gist.githubusercontent.com/sidneys/0a5bea36f989d445cdfbd776023a94ca/raw/ // @version 2.1.2 // @description Disabled automatic playback ("Autoplay") of YouTube videos. // @author sidneys // @icon https://www.youtube.com/favicon.ico // @include http*://www.youtube.com/* // @require https://greasyfork.org/scripts/38888-greasemonkey-color-log/code/Greasemonkey%20%7C%20Color%20Log.js // @run-at document-start // ==/UserScript== /** * ESLint configuration * @external */ /* global DEBUG */ /** * @default * @constant */ DEBUG = false /** * @default * @constant */ const urlPath = '/watch' /** * @default * @constant */ const didInit = false /** * Stop YouTube Video Player */ let stopPlayback = () => { //console.info('stopPlayback') ['play', 'playing', 'timeupdate'].forEach((eventName) => { const videoElement = document.querySelector('video') /** @listens video:Event */ videoElement.addEventListener(eventName, () => { console.debug('videoElement', eventName) const playerElement = document.querySelector('.html5-video-player') // Pause Video playerElement.pauseVideo() // Show Status console.info('Playback paused.', 'Media Event:', eventName, 'Player State:', playerElement.getPlayerState()) }, { once: true }) }) } /** * Init */ let init = () => { console.info('init') // Check URL if (!window.location.pathname.startsWith(urlPath)) { return } stopPlayback() } /** * Immediately Invoked Function Expression */ (() => { /** * This event hook covers initial page loading / reloading * @listens document:Event#readystatechange */ document.addEventListener('readystatechange', (event) => { console.info('document#readystatechange', document.readyState) if (document.readyState === 'interactive') { init() } }) /** * This event hook covers follow-up in-page navigation (Classic YouTube web platform) * @listens window:Event#spfdon */ window.addEventListener('spfdone', () => { console.info('window#spfdone') init() }) /** * This event hook covers in-page navigation within the (Polymer YouTube web platform) * @listens window:Event#spfdon */ window.addEventListener('yt-navigate-finish', () => { console.info('yt-navigate-finish') init() }) })()