Youtube fix share url

Remove tracking parametr "si" from video link from share button

< 脚本Youtube fix share url的反馈

评价:好评 - 脚本运行良好

§
发表于:2024-03-12

Dope! I modified it a little to not run on a timer. Go ahead and mod your script if you'd like so I can take mine down! :)
Please leave credit tho!


// ==UserScript==
// @name Youtube fix share url
// @namespace http://tampermonkey.net/
// @version 1
// @description Remove tracking parameter "si" from video link from share button
// @author SergoZar
// @match https://www.youtube.com/watch*
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @license GPLv3
// @downloadURL https://update.greasyfork.org/scripts/489533/Youtube%20fix%20share%20url.user.js
// @updateURL https://update.greasyfork.org/scripts/489533/Youtube%20fix%20share%20url.meta.js
// ==/UserScript==

(function() {
'use strict';

function fix_url(){
var share_url = document.getElementById("share-url");
if(share_url){
var url = new URL(share_url.value);
url.searchParams.delete("si");
share_url.value = url.toString();
}
}

var observer = new MutationObserver(fix_url);
observer.observe(document.documentElement, { subtree: true, childList: true });

// Initial fix
fix_url();
})();

§
发表于:2024-03-12

mb that code is wrong
this one functions


(function() {
'use strict';

function fix_url(){
var share_url = document.getElementById("share-url");
if(share_url){
var url = new URL(share_url.value);
url.searchParams.delete("si");
share_url.value = url.toString();
}
}

var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.type === "attributes" && mutation.attributeName === "aria-checked") {
fix_url();
}
});
});

observer.observe(document.body, { subtree: true, attributes: true });

})();

§
发表于:2024-03-12

The code tags are ass so here is a pastebin.

SergoZar作者
§
发表于:2024-04-04

After several hours of trying to use your code variation, I was unable to fix the problem where the attribute is not removed after changing the time in the video. Maybe the MutationObserver doesn't see changes in the value attribute when the video time changes.

However, I added your code as one of the versions so you might want to install it if it works well for you:
https://greasyfork.org/uk/scripts/489533-youtube-fix-share-url?version=1354329

发表回复

登录以发表回复。