Youtube clear

Disables video recommendations on the front page and video viewing pages of youtube.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Youtube clear
// @version      0.2
// @description  Disables video recommendations on the front page and video viewing pages of youtube.
// @author       You
// @include http://youtube.com/*
// @include http://www.youtube.com/*
// @include https://youtube.com/*
// @include https://www.youtube.com/*
// @namespace https://greasyfork.org/users/12940
// @grant        none
// ==/UserScript==

window.setInterval(function(){
    erase();
}, 500);

function erase(){

    var query = getQueryParams(document.location.search);

    if(query.list == null){
        var menus = document.getElementsByClassName("branded-page-v2-container branded-page-base-bold-titles branded-page-v2-container-flex-width branded-page-v2-secondary-column-hidden");
        for (var i = menus.length - 1; i >= 0; i--)
        {
            menus[i].style.display = "none";
        }
    }

    if(query.watch == null){
        var sidebar = document.getElementsByClassName("watch-sidebar-section");
        for (var i = sidebar.length - 1; i >= 0; i--)
        {
            sidebar[i].style.display = "none";
        }
    }
}

erase();

function getQueryParams(qs) {
    qs = qs.split('+').join(' ');

    var params = {},
        tokens,
        re = /[?&]?([^=]+)=([^&]*)/g;

    while (tokens = re.exec(qs)) {
        params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
    }

    console.log(params);
    return params;
}