Instantly share code, notes, and snippets.
Last active
January 9, 2026 00:45
-
Star
0
(0)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
-
Save Fizzyhex/ffeabbcc3aa7c04d2f21b9fbea16909b to your computer and use it in GitHub Desktop.
Tampermonkey script that strips tracking data from YouTube's share modal.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name purple share | |
| // @namespace http://tampermonkey.net/ | |
| // @version 2025-11-20 | |
| // @description remove tracker from share links | |
| // @author fizzy | |
| // @match https://www.youtube.com/watch* | |
| // @match https://www.youtube.com/shorts* | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com | |
| // @grant none | |
| // ==/UserScript== | |
| //[!]use-purple-cores 5 | |
| (function () { | |
| 'use strict'; | |
| var lastPurple; | |
| /** | |
| * @param {[Element]} element | |
| * @return {[null]} | |
| */ | |
| function purple_link(element) { | |
| console.log("purple patching"); | |
| element.removeAttribute("readonly"); | |
| const safeUrl = element.value.replace(new RegExp("\\?.*"), ""); | |
| const paramsArray = element.value.match(new RegExp("([^\\?]*$)")); | |
| if (paramsArray.length === 0) { | |
| console.log("no param") | |
| return; | |
| } | |
| const params = paramsArray[0].split("&"); | |
| const goodParams = []; | |
| params.forEach((x) => { | |
| if (!x.startsWith("si=")) { | |
| goodParams.push(x); | |
| } | |
| }) | |
| if (goodParams.length > 0) { | |
| console.log(goodParams, params, paramsArray); | |
| console.log(`${safeUrl}?${goodParams.join("&")}`) | |
| element.value = `${safeUrl}?${goodParams.join("&")}`; | |
| } else { | |
| console.log("ok die"); | |
| // just make a safe version of the url without url params | |
| element.value = safeUrl; | |
| } | |
| lastPurple = element; | |
| } | |
| /** | |
| * @param {[Element]} element | |
| * @return {[null]} | |
| */ | |
| function purple_stalk_checkbox(element) { | |
| const reset = () => { | |
| if (lastPurple) { | |
| purple_link(lastPurple) | |
| } | |
| } | |
| // overwrite the link again after timestamp box clicks | |
| const observer2 = new window.MutationObserver(reset); | |
| observer2.observe(element, { | |
| attributes: true, | |
| characterData: true, | |
| childList: true, | |
| subtree: true, | |
| attributeOldValue: true, | |
| characterDataOldValue: true | |
| }); | |
| } | |
| /** | |
| * @param {[Element]} element | |
| * @return {[null]} | |
| */ | |
| function purple_button(element) { | |
| console.log("HAHAHAH DIEEEE BTN // Please donate to our ko-fi: https://youtube.com/youtube-premium?si=joOSD7j"); | |
| element.style.setProperty("transition-property", "background"); | |
| element.style.setProperty("transition-duration", "0.25s"); | |
| element.style.setProperty("transition-delay", "0.3s"); | |
| element.style.setProperty("background", "#9561bd", "important"); | |
| } | |
| // ho ho ho | |
| function startPolling(node) { | |
| const poll1 = () => { | |
| setTimeout(function () { | |
| var purple = node.querySelector("#share-url") | |
| if (purple) { | |
| console.log("[π£] HAHAHAH DIEEEE ποΈββοΈπͺ³"); | |
| purple_link(purple); | |
| } else { | |
| poll1(); | |
| } | |
| }, 100); | |
| } | |
| const poll2 = () => { | |
| setTimeout(function () { | |
| var purpleify = node.querySelector(".yt-spec-button-shape-next"); | |
| if (purpleify) { | |
| purple_button(purpleify); | |
| } else { | |
| console.log("[π£] DIE NOW"); | |
| poll2(); | |
| } | |
| }, 100); | |
| } | |
| const poll3 = () => { | |
| setTimeout(function () { | |
| var purpleify = node.querySelector("#checkbox"); | |
| if (purpleify) { | |
| purple_stalk_checkbox(purpleify) | |
| } else { | |
| poll3(); | |
| } | |
| }, 100); | |
| } | |
| poll1(); | |
| poll2(); | |
| poll3(); | |
| } | |
| function observe(root) { | |
| const observer = new window.MutationObserver(function (mutationList, observer) { | |
| for (const mutation of mutationList) { | |
| for (const node of mutation.addedNodes) { | |
| if (!node instanceof Element) continue; | |
| if (node.id === "copy-link") { | |
| console.log("[π£] DIE GOOGLE DIE!!!!!"); | |
| // we need 2 do this shit because google uses shadow doms for the css under here and mutation observers dont work on it | |
| // poll the parentNode to capture the timestamp checkbox too - it's not under here | |
| startPolling(node.parentNode); | |
| return; | |
| } | |
| } | |
| } | |
| }); | |
| observer.observe(root, { childList: true, subtree: true }); | |
| } | |
| observe(document.body); | |
| // patch the share box if its already there | |
| var existingBox = document.getElementById("share-url"); | |
| if (existingBox != null) purple_link(existingBox); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment