YouTube Remove List from Watch URLs

Remove list parameter from watch links on pages under www.youtube.com/user/.

  1. // ==UserScript==
  2. // @name YouTube Remove List from Watch URLs
  3. // @author Jefferson "jscher2000" Scher
  4. // @namespace JeffersonScher
  5. // @description Remove list parameter from watch links on pages under www.youtube.com/user/.
  6. // @version 0.1
  7. // @copyright Copyright 2014 Jefferson Scher
  8. // @license BSD 3-clause
  9. // @include http*://www.youtube.com/user/*
  10. // @grant GM_log
  11. // ==/UserScript==
  12.  
  13. function cleanseURLs(el){
  14. var dirty, i, u;
  15. dirty = el.querySelectorAll("a[href*='/watch?v='][href*='&list=']");
  16. for (i=0; i<dirty.length; i++){
  17. u = dirty[i].href;
  18. dirty[i].href = u.substr(0, u.indexOf("&list="));
  19. }
  20. }
  21.  
  22. // run initial cleanse
  23. cleanseURLs(document.body);
  24.  
  25. // set up mutation observer to detect added videos
  26. var YRLWU_MutOb = (window.MutationObserver) ? window.MutationObserver : window.WebKitMutationObserver;
  27. if (YRLWU_MutOb){
  28. var YRLWU_chgMon = new YRLWU_MutOb(function(mutationSet){
  29. mutationSet.forEach(function(mutation){
  30. for (var i=0; i<mutation.addedNodes.length; i++){
  31. if (mutation.addedNodes[i].nodeType == 1){
  32. cleanseURLs(mutation.addedNodes[i]);
  33. }
  34. }
  35. });
  36. });
  37. // attach chgMon to document.body
  38. var opts = {childList: true, subtree: true};
  39. YRLWU_chgMon.observe(document.body, opts);
  40. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址