HWM_Tavern_AutoAccept_BlackList_Notification

Скрипт для таверны, автоматически отклоняет людей что в черном списке / принимает игру либо воспроизводит оповещения об вступления в заявку.

目前為 2020-05-23 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

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