Remove Youtube Autoplay

Remove autoplay from video suggestions on youtube

当前为 2018-07-02 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Remove Youtube Autoplay
// @namespace   https://gitlab.com/helq
// @description Remove autoplay from video suggestions on youtube
// @include     http://www.youtube.com/*
// @include     https://www.youtube.com/*
// @version     0.1.0
// @grant       none
// @author      helq
// @license     CC0
// ==/UserScript==

// Script based from:
// http://greasyfork.org/scripts/7893 by @wxc (https://greasyfork.org/en/users/8868-wxc)

function f() {
  "use strict";
  
  try {
    //console.log("Detecting autoplay");
    let node = document.getElementById('improved-toggle');
    if (node.hasAttribute('active')) {
      console.log("Autoplay on. Turning it off");
      node.click();
      document.body.removeEventListener('DOMSubtreeModified', f, false);
    }
  }
  catch (e) {}
}
f();
document.body.addEventListener('DOMSubtreeModified', f, false);
setTimeout(f, 400);