YouTube Tracking Param Remover

Dynamically checks for and removes nuisance/tracking parameters on links within YouTube pages. This helps to reduce tracking and helps keep your history clean, making visited links work properly.

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         YouTube Tracking Param Remover
// @namespace    YTParams
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  Dynamically checks for and removes nuisance/tracking parameters on links within YouTube pages. This helps to reduce tracking and helps keep your history clean, making visited links work properly.
// @author       BoffinBrain
// @license      MIT
// @match        https://www.youtube.com/*
// @icon         https://icons.duckduckgo.com/ip2/youtube.com.ico
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const ytEvents = ["yt-action", "yt-enable-lockup-interaction", "yt-renderidom-finished"];
    const badParams = ["pp", "si"];
    const query = badParams.map(p => 'a[href*="&' + p + '="]').join();

    const cleaner = ev => {
        const links = document.querySelectorAll(query);

        if (links.length) {
            console.log("YouTube Tracking Param Remover found " + links.length + " link(s) after event " + ev.type);

            links.forEach(link => {
                const urlParts = link.href.split("?");
                const params = new URLSearchParams(urlParts[1]);
                badParams.forEach(param => params.delete(param));
                link.href = urlParts[0] + "?" + params.toString();
            });
        }
    };

    ytEvents.forEach(e => {document.addEventListener(e, cleaner)});

    // Utility function to disover custom events firing on a webpage (@grant unsafeWindow required)
    // const dispatchEventOriginal = EventTarget.prototype.dispatchEvent;
    // unsafeWindow.EventTarget.prototype.dispatchEvent = function (event) {
    //     console.log(event.type);
    //     dispatchEventOriginal.apply(this, arguments);
    // };

    // List of discovered events that fire on YT:
    // active-changed
    // active-endpoint-changed
    // can-show-more-changed
    // dom-change
    // guide-persistent-and-visible-changed
    // guide-persistent-changed
    // image-loaded
    // image-unloaded
    // iron-request-resize-notifications
    // iron-resize
    // mini-guide-visible-changed
    // render-guide-changed
    // shown-items-changed
    // yt-action
    // yt-autonav-pause-guide-closed
    // yt-enable-lockup-interaction
    // yt-get-context-provider
    // yt-guide-hover
    // yt-navigate-finish
    // yt-page-data-fetched
    // yt-page-data-updated
    // yt-rendererstamper-finished
    // yt-renderidom-finished
    // yt-request-elements-per-row
    // yt-service-request-sent
    // yt-set-fullerscreen-styles
    // yt-text-inline-expander-expanded-changed
    // yt-update-title
})();