Reddit RES Style Class

Adds class to html for subreddit RES style on/off

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Reddit RES Style Class
// @namespace    http://your.homepage/
// @version      1.0
// @description  Adds class to html for subreddit RES style on/off
// @author       muffleyd
// @match        http*://*.reddit.com/r/*
// @grant        none
// @run-at document-body
// ==/UserScript==

var classname = 'no-subr-style'
var classname2 = 'yes-subr-style'
var $html = $('html')
$html.addClass(classname2)

window.addEventListener ("load", function () {

var toggleStyle = function () {
    $html.removeClass(classname).removeClass(classname2)
    if ($('head link[title="applied_subreddit_stylesheet"]').length == 0) {
        $html.addClass(classname)
    } else {
        $html.addClass(classname2)
    }
    /*if ($el.length) {
        if (!$el[0].checked) {
            $html.addClass(classname)
        } else {
            $html.addClass(classname2)
        }
    }*/
}

var $el = $('')
var refresh$el = function () {
    $el.off('click', toggleStyle)
    $el = $('.res-sr-style-toggle > input[type=checkbox]')
    if ($el.length) {
        $el.on('change', toggleStyle)
    }
}

document.addEventListener('visibilitychange', function () {
    if (!document.hidden) {
        refresh$el()
        toggleStyle()
    }
})

refresh$el()
toggleStyle()

})