Youtube End-Screen Remover (End Screen disposer)

Remove annoyed end-screens on youtube videos

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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
})();