🏠 Home 

reddit default theme

Disable reddit custom subreddits themes, fallback to the default one.


Install this script?
  1. // ==UserScript==
  2. // @name reddit default theme
  3. // @description Disable reddit custom subreddits themes, fallback to the default one.
  4. // @namespace https://greasyfork.org/scripts/29326
  5. // @include http://www.reddit.com/*
  6. // @include https://www.reddit.com/*
  7. // @include http://np.reddit.com/*
  8. // @include https://np.reddit.com/*
  9. // @include http://xm.reddit.com/*
  10. // @include https://xm.reddit.com/*
  11. // @version 2
  12. // @grant none
  13. // @run-at document-start
  14. // ==/UserScript==
  15. 'use strict';
  16. function find_and_delete_theme(node)
  17. {
  18. if (node.nodeType === Node.ELEMENT_NODE &&
  19. node.nodeName.toLowerCase() === 'link' &&
  20. node.getAttribute('rel') === 'stylesheet' &&
  21. node.getAttribute('title') === 'applied_subreddit_stylesheet') {
  22. node.parentNode.removeChild(node);
  23. return true;
  24. }
  25. }
  26. function delete_if_present()
  27. {
  28. if (document.head) {
  29. for (var node of document.head.childNodes) {
  30. if (find_and_delete_theme(node))
  31. return true;
  32. }
  33. }
  34. }
  35. function delete_when_inserted()
  36. {
  37. (new MutationObserver(function(records, observer) {
  38. for (var record of records) {
  39. for (var node of record.addedNodes) {
  40. if (find_and_delete_theme(node)) {
  41. observer.disconnect();
  42. return;
  43. }
  44. }
  45. }
  46. })).observe(document, {childList: true, subtree: true});
  47. }
  48. delete_if_present() || delete_when_inserted();