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 για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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 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()

})