YouTube Remove Share URL Tracking

Remove tracking parameter "si" in video link from share button

  1. // ==UserScript==
  2. // @name YouTube Remove Share URL Tracking
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0.1
  5. // @description Remove tracking parameter "si" in video link from share button
  6. // @author SergoZar, satandidnowrong
  7. // @match https://www.youtube.com/watch*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
  9. // @license Creative Commons Attribution-NonCommercial 4.0 International License
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. function fix_url(){
  16. var share_url = document.getElementById("share-url");
  17. if(share_url){
  18. var url = new URL(share_url.value);
  19. url.searchParams.delete("si");
  20. share_url.value = url.toString();
  21. }
  22. }
  23.  
  24. var observer = new MutationObserver(function(mutations) {
  25. mutations.forEach(function(mutation) {
  26. if (mutation.type === "attributes" && mutation.attributeName === "aria-checked") {
  27. fix_url();
  28. }
  29. });
  30. });
  31.  
  32. observer.observe(document.body, { subtree: true, attributes: true });
  33.  
  34. })();