Clean YouTube Links

Cleans YouTube Links

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Clean YouTube Links
// @version      0
// @namespace    cleanytsi
// @description  Cleans YouTube Links
// @author       (me)
// @match       *://8chan.moe/*/res/*
// @match       *://8chan.se/*/res/*
// @match       *://8chan.cc/*/res/*
// @run-at       document-idle
// @grant        none
// ==/UserScript==

(function() {
    "use strict";
    const target = document.getElementById("threadList");
    const observer = new MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
            document.querySelectorAll('.divMessage a:not(.quoteLink)').forEach((link) => {
                if(link.href.includes("youtu") && link.href.includes("si=")) {
                    let stringindex = link.href.indexOf("si=")
                    let sanitized = link.href.split(link.href.substring(stringindex, stringindex+19)).join("")

                    if(sanitized.substring(sanitized.length-1) == "?") {
                        sanitized = sanitized.slice(0, sanitized.length-1)
                    }

                    if(sanitized.includes("?&")) {
                        sanitized = sanitized.split("?&").join("?")
                    }

                    link.textContent = sanitized
                    link.href = sanitized
                }
            });
        });
    });

    const config = {
        subtree: true,
        childList: true
    };

    observer.observe(target, config);
})();