Twitch bot detector

Запрашивает у апи твича количество зрителей и юзеров чата, сравнивая показатели

Stan na 16-01-2017. Zobacz najnowsza wersja.

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 bot detector
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Запрашивает у апи твича количество зрителей и юзеров чата, сравнивая показатели
// @author       Андрей Д
// @match        https://www.twitch.tv/*
// @grant        none
// @run-at       document-idle
// ==/UserScript==

var viewers = 0;
var chatters = 0;

var xhr = new XMLHttpRequest();

function connect(channel_name){
    var theUrl = 'https://api.twitch.tv/kraken/streams/'+channel_name;
$.ajax({
        url: theUrl,
        dataType: "jsonp",
        success: function( response ) {
            var viewerlist = response.stream.viewers;
            viewers = viewerlist;
            if(viewerlist !== ""){
                console.log('#######################################'+'\nЗрителей '+viewers);
            }else{
                  console.log("Не могу получить чаттеров");
            }
        }
    });
}

function chat (name){
var theUrl = 'https://tmi.twitch.tv/group/user/'+name+'/chatters';
$.ajax({
        url: theUrl,
        dataType: "jsonp",
        success: function( response ) {
            var viewerlist = response.data.chatter_count;
            chatters = viewerlist;
            if(viewerlist !== ""){
                console.log('#######################################'+'\nВ чате '+chatters);
            }else{
                  console.log('#######################################'+'\nНе могу получить чаттеров');
            }
        }
    });
}

function alg (view, chat) {

	return chat / view * 100;
}



//docReady(function() {
$(window).load(function(){
    console.log('#######################################'+'\nВыделяем имя стримера..');
    var twitchname;
    //var name1 = document.getElementsByClassName("links_group");
    var name1 = window.location.href;
    twitchname = name1.substr(22);
    /////
console.log('#######################################'+'\nЗагрузка..');
setTimeout(function(){
	connect(twitchname);
    chat(twitchname);
    setTimeout(function(){
    console.log('#######################################'+'\nДоля '+alg(viewers,chatters).toFixed(1));
    }, 5000);
}, 5000);
})();