My Twitch Drop Claimer

automatically clicks the "Claim" button

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name            My Twitch Drop Claimer
// @name:ru         My Twitch Drop Claimer
// @namespace       http://www.aazone.ru/
// @version         0.7
// @description     automatically clicks the "Claim" button
// @description:ru  автоматически нажимает кнопку "Получить"
// @author          Aaz
// @match           https://www.twitch.tv/*
// @match           *://*.twitch.tv/*
// @match           *://twitch.tv/*
// @icon            https://static.twitchcdn.net/assets/favicon-32-d6025c14e900565d6177.png
// @grant           none
// ==/UserScript==

/* jshint esversion: 6 */
 
(function() { 'use strict';
		
	const ClaimButtonNames = [
		'Claim', //English
		'Hent', //Dansk
		'Abholen', //Deutsch
		'Reclamar', //Español
		'Obtenir', //Français
		'Riscatta', //Italiano
		'Megszerzés', //Magyar
		'Claimen', //Nederlands
		'Motta', //Norsk
		'Odbierz', //Polski
		'Resgatar', //Português
		'Solicită', //Română
		'Vyzdvihnúť', //Slovenčina
		'Lunasta', //Suomi
		'Hämta', //Svenska
		'Nhận', //Tiếng Việt
		'Al', //Türkçe
		'Vyzvednout', //Čeština
		'Διεκδίκηση', //Ελληνικά
		'Заявяване', //Български
		'Получить', //Русский
		'เคลม', //ภาษาไทย
		'领取', //中文 简体
		'領取', //中文 繁體
		'受け取る', //日本語
		'받기', //한국어
	]
	
	const CloseChatRulesButtonName = ['chat-rules-ok-button', ]; 
	
	var ClaimButtonClass = '';	
	var CloseChatRulesButtonClass = '';
	
	const GetClass = function (But, PressIt, ignorName) {
		
		let ButtonClass = '';
		
		const yNode = document.querySelectorAll('button');
		
		if (yNode) {
			
			let s = '';
			
			for (let i = 0; i < yNode.length; i++) {
				
				s = '';
				
				if (!ignorName) {
					s = yNode.item(i).textContent;
				}
				
				if (s == '' && yNode.item(i).attributes[1]) {
					s = yNode.item(i).attributes[1].nodeValue;
				}
				
				if (s != '' && But.includes(s)) {
					ButtonClass = '.' + yNode.item(i).classList.value.replace(/ /ig, '.');
					if (PressIt) {
						yNode.item(i).click();	
						console.log('Button "' + s + '" is pressed');
					}
					break;
				}
			}           
		}
 
		return ButtonClass;	
		
	}
	
    const GetClaimButton = () => {
 
		if (ClaimButtonClass == '') {
			ClaimButtonClass = GetClass(ClaimButtonNames, false, false);
		} 
		
		if (ClaimButtonClass != '') {
			const xNode = document.querySelector(ClaimButtonClass);
 
			if (xNode) {
				xNode.click();
				console.log('Claim drop button is pressed');
			}			
		}
		
		if (CloseChatRulesButtonClass == '') {
			CloseChatRulesButtonClass = GetClass(CloseChatRulesButtonName, true, true);
		} 
 
    };
	
	setInterval(GetClaimButton, 5000);

})();