Youtube End-Screen Remover (End Screen disposer)

Remove annoyed end-screens on youtube videos

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Youtube End-Screen Remover (End Screen disposer)
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  Remove annoyed end-screens on youtube videos
// @author       #EMBER (htps://fb.com/embermaxx)
// @match        *://www.youtube.com/*
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
var intvl, i=0, loop = 3E3, ig = 0;
//startToAppend -> Time for wait till YouTube classes load;
setInterval(checkIfAppend, loop);
//loop = check interval for new End-Screens;

function appendElement() {
    var el = document.createElement("div");
    el.id = "ess-info";
    el.style.textAlign = "center";
    el.style.fontSize = "17px";
    el.style.padding = "8px 8px";
    el.style.marginRight = "6px";
    el.style.backgroundColor = "rgba(255,255,255,0.1)";
    el.style.color = "#f1f1f1";
    el.style.border = "none";
    el.style.borderRadius = "17px";
    el.style.cursor = "pointer";
    el.setAttribute("title", "Total Disposed End-Screens");
    el.style.userSelect = "none";

    el.addEventListener("mouseover", function() {
        el.setAttribute("title", "Total "+ig+" End-Screens were Disposed!");
        el.style.backgroundColor = "rgba(128,128,128,0.5)"; // Gray style on hover
    });

    // Mouseout event listener
    el.addEventListener("mouseout", function() {
        el.style.backgroundColor = "rgba(255,255,255,0.1)"; // Original color
    });

    var actionsElement = document.getElementById("top-level-buttons-computed");
    if(actionsElement == null)
        actionsElement = document.getElementById("actions");
    actionsElement.insertBefore(el, actionsElement.firstChild);

}

    function addIndicator(element){
        var span = document.createElement("span");
        span.id="ess-info-ind";
        span.textContet = "✋ 0";
        element.append(span);
    }

    function checkIfAppend()
    {
        let essInfo = document.getElementById("ess-info");
        let essInfoInd = document.getElementById("ess-info-ind");

        if(essInfo == null)
            appendElement();
        if(essInfoInd == null && essInfo != null)
           addIndicator(essInfo);
        removeEndScreens("ytp-ce-element");
    }

function removeEndScreens(className){
    var elements = document.getElementsByClassName(className);
    while(elements.length > 0){
        if(elements[0].parentNode.removeChild(elements[0])){
            ig = ++i;
            let essInfoInd = document.getElementById("ess-info-ind");
            if(essInfoInd != null)
                essInfoInd.textContent = "✋ "+i;
            else
                checkIfAppend();

            console.log("Disposed ES Count: "+i);}
        else{
            console.log("No ES found");
        }
    }
}
    //Script by #EMBER
})();