youtube_ex

enhanced youtube

目前為 2016-02-04 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name youtube_ex
  3. // @description enhanced youtube
  4. // @namespace http://userscripts.org/users/
  5. // @include https://www.youtube.com/*
  6. // @version 0.1
  7. // ==/UserScript==
  8.  
  9. //====== common ========
  10. var obv_cfg={attributes: false, childList: true, characterData: false};
  11.  
  12. function observer_factory(callback, isforeach=true)
  13. {
  14. var cb=isforeach ? function(mutations) {mutations.forEach(callback);} : callback;
  15. return new MutationObserver(cb);
  16. }
  17.  
  18. function simpleRemoveElement(sel)
  19. {
  20. var sep=sel.indexOf("##");
  21. var selector=sep>=0 ? sel.substr(sep+2) : sel;
  22. var node=document.querySelector(selector);
  23. if (node) node.parentNode.removeChild(node);
  24. }
  25.  
  26. function killElementAttribute(attrname)
  27. {
  28. var nodes=document.querySelectorAll('['+attrname+']');
  29. for (var i=0;i<nodes.length;i++)
  30. {
  31. nodes[i].removeAttribute(attrname);
  32. }
  33. }
  34.  
  35. //======= end of common =========
  36.  
  37. function trackless()
  38. {
  39. observer_factory(function (stub) {
  40. killElementAttribute("data-sessionlink");
  41. killElementAttribute("data-visibility-tracking");
  42. },false).observe(document.body, obv_cfg);
  43. }
  44.  
  45.  
  46. trackless();
  47.