LNK_checkArts

проверка изменения кол-ва надетых артов

当前为 2021-06-13 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         LNK_checkArts
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  проверка изменения кол-ва надетых артов
// @author       LNK
// @include      *heroeswm.ru/war.php*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

function notifyMes(title,mes) {
	if (!("Notification" in window)) {alert("Ваш браузер не поддерживает сообщения на рабочий стол!"); return false;}
	if (title == undefined) {title = "Some message from HWM!";}
	if (Notification.permission === "granted") {var notification = new Notification(title, {body : mes});}
	else {
		Notification.requestPermission(function (permission) {
			if (permission === "granted") {var notification = new Notification(title, {body : mes});}
		});
	}
} // notifyMes

function beep(duration, frequency, delay, gain) {
	var context = new (window.AudioContext || window.webkitAudioContext)();
	var gainNode = context.createGain();
	if (gain == undefined) {gain = 0.05;}
	gainNode.connect(context.destination);
	gainNode.gain.value = gain;
	var osc = context.createOscillator();
	osc.connect(gainNode);
	osc.type = 'square';
	if (frequency == undefined) {frequency = 350;}
	osc.frequency.value = frequency;
	if (delay == undefined) {delay = 50;}
	if (duration == undefined) {duration = 200;}
	setTimeout(function() {	osc.start(); setTimeout(function () { osc.stop(); }, duration);	}, delay);
	return osc;
} // beep

function getPage(aURL) {
	var xhr = new XMLHttpRequest();
	xhr.open('GET', aURL, false);
	xhr.overrideMimeType('text/html; charset=windows-1251');
	xhr.send();
	if (xhr.status != 200) {
		return ( 'Ошибка ' + xhr.status + ': ' + xhr.statusText );
	} else {
		return ( xhr.responseText );
	}
} // getPage


var resWin, resText;
var artsNum = GM_getValue('HWMartsNum', 0);

	function checkArts() {
		resWin = document.getElementById("finalresult_text");
		resText = resWin.innerHTML;
        if (resText.length > 10) {
            clearInterval(timerId);
            var pText = getPage('home.php');
            var count = 0;
            for (var i = 0; i < pText.length; i++) {
                var index = pText.indexOf('cre_mon_image1"><img src="https://dcdn', i);
                if (index != -1) {
                    count++;
                    i = index;
                }
            } //alert(count+' '+artsNum+' '+(artsNum-count));
            if (count < artsNum) {
                //		beep(500);
                setTimeout(() => notifyMes('Arts Check: арт сломан!'), 700);
                alert('Уменьшилось количество надетых предметов!!!  - '+(artsNum-count));
                GM_setValue('HWMartsNum', count);
            }
            GM_setValue('HWMartsNum', count);
        }
	} //checkArts
	var timerId = setInterval(checkArts, 2000);
})();