Remove custom css on VOAT

Removes the dark custom CSS theme from subverses on VOAT.com

目前为 2015-08-16 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Remove custom css on VOAT
  3. // @include https://voat.co/*
  4. // @include https://www.voat.co/*
  5. // @description Removes the dark custom CSS theme from subverses on VOAT.com
  6. // @version 1.0
  7. // @author wOxxOm
  8. // @namespace wOxxOm.scripts
  9. // @license MIT License
  10. // @run-at document-start
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. setMutationHandler(document, '#custom_css', function(observer, nodes) {
  15. [].forEach.call(nodes, function(node) { node.remove() });
  16. if (!observer.stopped)
  17. (function() {
  18. document.addEventListener("DOMContentLoaded", function() {
  19. observer.disconnect();
  20. observer.stopped = true;
  21. });
  22. })();
  23. return true;
  24. });
  25.  
  26. function setMutationHandler(baseNode, selector, cb) {
  27. var ob = new MutationObserver(function(mutations){
  28. for (var i=0, ml=mutations.length, m; (i<ml) && (m=mutations[i]); i++)
  29. for (var j=0, nodes=m.addedNodes, nl=nodes.length, n; (j<nl) && (n=nodes[j]); j++)
  30. if (n.nodeType == 1)
  31. if ((n = n.matches(selector) ? [n] : n.querySelectorAll(selector)) && n.length)
  32. if (!cb(ob, n))
  33. return;
  34. });
  35. ob.observe(baseNode, {subtree:true, childList:true});
  36. }