Twilight Heroes Autobox

This script adds a button for getting and equipping black box in the web game Twilight Heroes.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name            Twilight Heroes Autobox
// @description     This script adds a button for getting and equipping black box in the web game Twilight Heroes.
// @namespace       Twilight Heroes
// @match           https://www.twilightheroes.com/criminology.php*
// @match           https://twilightheroes.com/criminology.php*
// @match  	        https://www.twilightheroes.com/main.php*
// @match  	        https://twilightheroes.com/main.php*
// @version         2
// @history         v2: The script broke when the game switched over to HTTPS. v2 fixes this issue. also replaced include with match for wider compatibility
// @history         v1: Initial script by Heather Robinson, whose scrips can be found here https://userscripts-mirror.org/users/110369
// ==/UserScript==

function zz(){
	var t='https://'+location.host+'/criminology.php';
	localStorage.setItem('gfb','true');
	location.href=t;}

if(/main/.exec(location.href)){
	var c=document.getElementsByTagName('center')[0];
	var b=document.createElement('button');
	b.innerHTML='Get & Equip Black Box';
	c.parentNode.insertBefore(b,c);
	b.addEventListener('click',zz,true);}
else if(localStorage.getItem('gfb')){
	var a=document.getElementsByTagName('form');
	if(a.length>3)
		a[2].submit();
	else{
		a=document.getElementsByTagName('a')[0];
		localStorage.removeItem('gfb');
		location.href=a.href;}}