Twitch Russian Filter

Filter russian streams from games.

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         Twitch Russian Filter
// @namespace    https://github.com/d3xtr0/
// @version      0.3
// @description  Filter russian streams from games.
// @author       d3xtr0
// @match        *.twitch.tv/*
// @grant        none
// ==/UserScript==


(function() {
	'use strict';
	
	/*
	Tampermonkey: Go to settings > "Run only in main-frame": Yes
	*/
    
	// 0 => empty placeholder
	// 1 => no placeholder
	var toggleRemove = 0;
    
	// check every x ms for new streams
	var speed = 2000;
	
	// russian alphabet
	var keys = [
		"{ru", "[ru", "(ru", "ru]", "ru)", "ru}",
		"б", "в", "г", "д", "ж", "з", "и", "й", "п", "ф", "ц", "ч", "ш", "щ", "ъ", "ы", "ь", "э", "ю", "я"
	];
    
	$(function(){
		console.log("[Russian Filter] started");

		if(toggleRemove){
			$('head').append('<style>.tw-hidden{display:none;}</style>');
		}else{
			$('head').append('<style>.tw-hidden{visibility:hidden;}</style>');
		}

		var init = window.setInterval(function(){
		    	var content = $(".js-directory.tse-content .streams");
		    	var contheight =  content.height();

			if(content.length){
			    removeRus();
			}
		}, speed);

		function removeRus(){
			$(".stream.item").each(function(i){

				var meta = $(this).find(".meta").text().toLowerCase();

				for(var x = 0; x < keys.length; x++){
					if(meta.indexOf(keys[x]) >= 0) {
						$(this).addClass("tw-hidden");
						break;
					}
				}

			});
		}

	});
})();