Youtube fix share url

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

  1. // ==UserScript==
  2. // @name Youtube fix share url
  3. // @namespace http://tampermonkey.net/
  4. // @version 6
  5. // @description Remove tracking parametr "si" from video link from share button
  6. // @author SergoZar
  7. // @match https://www.youtube.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
  9. // @license GPLv3
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. function fix_url(){
  15. var share_url = document.getElementById("share-url");
  16. if(share_url){
  17. var url = new URL(share_url.value);
  18. url.searchParams.delete("si");
  19. share_url.value = url.toString();
  20. }
  21. }
  22. // thanks https://greasyfork.org/uk/users/1273743-satandidnowrong for this code)
  23. var observer = new MutationObserver(function(mutations) {
  24. mutations.forEach(function(mutation) {
  25. if (mutation.type === "attributes" && mutation.attributeName === "aria-checked") {
  26. fix_url();
  27. }
  28. });
  29. });
  30. observer.observe(document.body, { subtree: true, attributes: true });
  31. })();