DeviantArt NSFW Filter

Toggle between NSFW, SFW or all posts on DA galleries and pages.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         DeviantArt NSFW Filter
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Toggle between NSFW, SFW or all posts on DA galleries and pages.
// @author       You
// @match        https://www.deviantart.com/*/favourites/*
// @match https://www.deviantart.com
// @match https://www.deviantart.com/*/gallery/*
// @match https://www.deviantart.com/*/?q=*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var newstyle = document.createElement("style");
    newstyle.setAttribute("type","text/css");
    newstyle.setAttribute("id","nsfwfilter");
    newstyle.innerHTML = ".ad-container{display:none !important;}";
    document.body.appendChild(newstyle);

    var button = document.createElement("td");
    button.setAttribute("style","padding-right:10px;")
    button.setAttribute("id","nsfwbutton")
    button.innerHTML= "NSFW: ALL"
    document.querySelector("#overhead > tbody > tr").insertBefore(button,document.querySelector("#oh-menu-deviant"))

    function nsfwonly(){
        document.querySelector("#nsfwfilter").innerHTML = ".thumb:not(.ismature), .ad-container{display:none !important;}";
        document.querySelector("#nsfwbutton").innerHTML = "NSFW: ON";
    }
    function sfwonly(){
        document.querySelector("#nsfwfilter").innerHTML = ".ismature, .ad-container{display:none !important;}";
        document.querySelector("#nsfwbutton").innerHTML = "NSFW: OFF";
    }
    function allposts(){
        document.querySelector("#nsfwfilter").innerHTML = ".ad-container{display:none !important;}";
        document.querySelector("#nsfwbutton").innerHTML = "NSFW: ALL";
    }

    document.querySelector("#nsfwbutton").onclick = function toggleNSFW(){
        var state = document.querySelector("#nsfwfilter").textContent;
        switch(state){
            case ".thumb:not(.ismature), .ad-container{display:none !important;}":
                sfwonly();
                break;
            case ".ismature, .ad-container{display:none !important;}":
                allposts();
                break;
            case ".ad-container{display:none !important;}":
                nsfwonly();
                break;
        }
    }
})();