reddit default theme

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        reddit default theme
// @description Disable reddit custom subreddits themes, fallback to the default one.
// @namespace   https://greasyfork.org/scripts/29326
// @include     http://www.reddit.com/*
// @include     https://www.reddit.com/*
// @include     http://np.reddit.com/*
// @include     https://np.reddit.com/*
// @include     http://xm.reddit.com/*
// @include     https://xm.reddit.com/*
// @version     2
// @grant       none
// @run-at      document-start
// ==/UserScript==
'use strict';

function find_and_delete_theme(node)
{
if (node.nodeType === Node.ELEMENT_NODE &&
    node.nodeName.toLowerCase() === 'link' &&
    node.getAttribute('rel') === 'stylesheet' &&
    node.getAttribute('title') === 'applied_subreddit_stylesheet') {
    node.parentNode.removeChild(node);
    return true;
    }
}

function delete_if_present()
{
    if (document.head) {
        for (var node of document.head.childNodes) {
            if (find_and_delete_theme(node))
            return true;
        }
    }
}

function delete_when_inserted()
{
    (new MutationObserver(function(records, observer) {
        for (var record of records) {
			for (var node of record.addedNodes) {
                if (find_and_delete_theme(node)) {
                    observer.disconnect();
                    return;
                }
            }
        }
    })).observe(document, {childList: true, subtree: true});
}

delete_if_present() || delete_when_inserted();