Greasy Fork

Greasy Fork is available in English.

bonk-simple

A userscript to add Simple back to bonk.io

当前为 2021-10-20 提交的版本,查看 最新版本

// ==UserScript==
// @name         bonk-simple
// @version      1.0.0
// @author       Blu ft. Salama
// @description  A userscript to add Simple back to bonk.io
// @match        https://bonk.io/gameframe-release.html
// @run-at       document-start
// @grant        none
// @namespace http://greasyfork.icu/users/826975
// ==/UserScript==

// this userscript is a remix of Salama's VTOL injector
// https://github.com/Salama/bonk-vtol/blob/master/injector.js

// for use as a userscript ensure you have Excigma's code injector userscript
// http://greasyfork.icu/en/scripts/433861-code-injector-bonk-io

const injectorName = `Simple`;
const errorMsg = `Whoops! ${injectorName} was unable to load.
This may be due to an update to Bonk.io. If so, please report this error!
This could also be because you have an extension that is incompatible with \
${injectorName}`;

function injector(src){
	newSrc = src;
	newSrc=newSrc.replace('[S9L.C1E(107),S9L.W1E(1130),S9L.C1E(1131),S9L.W1E(1132),',SIMPLE_MODE);
	newSrc=newSrc.replace('P1R[43][P1R[7][551]][S9L.C1E(1187)]={lobbyName:S9L.W1E(2088),gameStartName:S9L.W1E(2089),lobbyDescription:S9L.W1E(2090),tutorialTitle:S9L.W1E(2091),tutorialText:S9L.C1E(2092),forceTeams:false,forceTeamCount:null,editorCanTarget:false};', MAP_EDITOR_SIMPLE);

	if(src === newSrc) throw "Injection failed!";
	console.log(injectorName+" injector run");
	return newSrc;
}

// Adds Simple to mode selection button
const SIMPLE_MODE= `[S9L.C1E(107),S9L.W1E(1130),S9L.C1E(1131),S9L.W1E(1132),"bs",`;
// Adds Simple to map editor "For mode:" selector
const MAP_EDITOR_SIMPLE= `P1R[43][P1R[7][551]][S9L.C1E(1187)]={lobbyName:S9L.W1E(2088),gameStartName:S9L.W1E(2089),lobbyDescription:S9L.W1E(2090),tutorialTitle:S9L.W1E(2091),tutorialText:S9L.C1E(2092),forceTeams:false,forceTeamCount:null,editorCanTarget:true};`;

// Compatibility with Excigma's code injector userscript
if(!window.bonkCodeInjectors) window.bonkCodeInjectors = [];
window.bonkCodeInjectors.push(bonkCode => {
	try {
		return injector(bonkCode);
	} catch (error) {
		alert(errorMsg);
		throw error;
	}
});

console.log(injectorName+" injector loaded");