Скрипт для таверны, автоматически отклоняет людей что в черном списке / принимает игру либо воспроизводит оповещения об вступления в заявку.
目前為
// ==UserScript==
// @name HWM_Tavern_AutoAccept_BlackList_Notification
// @author emptimd
// @namespace emptimd
// @description Скрипт для таверны, автоматически отклоняет людей что в черном списке / принимает игру либо воспроизводит оповещения об вступления в заявку.
// @include /https?:\/\/(www.heroeswm.ru|178.248.235.15|www.lordswm.com)\/(tavern.php)/
// @version 1.0
// @grant none
// ==/UserScript==
/*
Variables
*/
// nicknames that the script will auto deny. To add a new nickname, place it inside quotes. '',
const blackList = ['','','',];
const autoAccept = 0; // 1 if should auto accept new games from players.
const soundAlert = 0; // 1 if should make a sound alert when some player made a request/script accepted request.
/*
Code
*/
// sound alarm
function beep(vol, freq, duration){
var a=new AudioContext();
var v=a.createOscillator()
var u=a.createGain()
v.connect(u)
v.frequency.value=freq
v.type="square"
u.connect(a.destination)
u.gain.value=vol*0.01
v.start(a.currentTime)
v.stop(a.currentTime+duration*0.001)
}
function make_alarm(){
if(document.visibilityState === 'hidden') {
beep(3, 300, 300);//first number stands for sound volume
}
}
let a = document.querySelector('a[href^="acard_game.php"]');
if(!a) throw new Error();
// check nickname
let nickname = a.previousSibling.previousSibling.childNodes[0].text;
if(blackList.includes(nickname)) {
// deny
window.open(a.nextElementSibling.href,'_self');
}else {
//sound alert.
if (soundAlert) make_alarm();
//auto accept.
if (autoAccept) window.open(a.href,'_self');
}