Reddit - Block NSFW

Redirects NSFW subreddits to another site.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name		Reddit - Block NSFW
// @description		Redirects NSFW subreddits to another site.
// @version		1.2
// @include		/^https?://.*\.reddit\.com/r/.*$/
// @license		GPLv3
// @grant		GM_xmlhttpRequest
// @namespace https://greasyfork.org/users/10480
// ==/UserScript==

var redirectUrl = "https://www.reddit.com";	// Set this to url you want to redirect to.

var url = document.URL;

if (url.substring(url.length-1) != "/")
{
	url = url + "/";
}

var jsonUrl = url + "about.json";

GM_xmlhttpRequest
({
	method: "GET",
	url: jsonUrl,
	onload: function(response)
	{
		var json = JSON.parse(response.responseText);
		if (json.data.over18 || json[0].data.children[0].data.over_18)
		{
			window.location.replace(redirectUrl);
		}
	}
});