reddit default theme

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==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();