Twitch Russian Filter

Filter russian streams from games.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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;
					}
				}

			});
		}

	});
})();