Greasy Fork is available in English.

editor rom pom pom

sillicirclegae

// ==UserScript==
// @name         editor rom pom pom
// @version      1.0
// @description  sillicirclegae
// @author       Apx
// @match        https://bonk.io/gameframe-release.html
// @match        https://bonkisback.io/gameframe-release.html
// @run-at       document-start
// @namespace    https://greasyfork.org/users/1272759
// @grant        none
// ==/UserScript==


function injector(src){
    let newSrc = src;
    let r1 = newSrc.match(/[a-zA-Z0-9\$_]{3}\[[0-9]{1,3}]]\[[a-zA-Z0-9\$_]{3}\[[0-9]{1,3}]\[[0-9]{1,3}]]=Math\[[a-zA-Z0-9\$_]{3}\[[0-9]{1,3}]\[[0-9]{1,3}]]\([a-zA-Z0-9\$_]{3}\[[0-9]{2,3}]\);[a-zA-Z0-9\$_]{3}\(true\)/)[0];
    let r2 = newSrc.match(/[a-zA-Z0-9\$_]{3}\[[0-9]{1,3}]\[[a-zA-Z0-9\$_]{3}\[[0-9]{1,3}]\[[0-9]{1,3}]]\[[0-1]]=Math\[[a-zA-Z0-9\$_]{3}\[[0-9]{1,3}]\[[0-9]{1,3}]]\([a-zA-Z0-9\$_\[\]]+\);/g).map((x) => {return x.split("=")});
    let r3 = newSrc.match(/function K\$N\(\){[a-zA-Z0-9-+=_ \$;\(\)[\]{}\.,!]*?N_A\(true\);}/g);
    let r4 = newSrc.match(/function [a-zA-Z0-9\$_]{3}\([a-zA-Z0-9\$_]{3}\){[a-zA-Z0-9\$_\[\]= ]+;[a-zA-Z0-9\$_\[\]=]+;[a-zA-Z0-9\$_\[\]=]+\*=10000;[a-zA-Z0-9\$_\[\]=]+\([a-zA-Z0-9\$_\[\]=]+\);[a-zA-Z0-9\$_\[\]=]+\/=10000;return [a-zA-Z0-9\$_\[\]=]+;}/)[0];

    // move up / down spawns
    newSrc = newSrc.replace(r3,`function K$N(){var U_2=[arguments];U_2[7]=M$QCc;U_2[4]=Z20[36][U_2[7][43]][U_2[7][334]][U_2[7][99]](Z20[360]);U_2[5]=Z20[36].spawns[Z20[285]];if(U_2[4] == -1 && Z20[36].spawns.indexOf(U_2[5]) == -1){return;}if(U_2[4] != -1){if(this == Z20[910]){if(Z20[36][U_2[7][43]][U_2[7][334]][U_2[4] - 1] != undefined){k7V.H0n(0);U_2[1]=Z20[36][U_2[7][43]][U_2[7][334]][k7V.w_c(U_2[4],1)];k7V.H0n(0);Z20[36][U_2[7][43]][U_2[7][334]][k7V.Q5$(U_2[4],1)]=Z20[36][U_2[7][43]][U_2[7][334]][U_2[4]];Z20[36][U_2[7][43]][U_2[7][334]][U_2[4]]=U_2[1];}}else if(this == Z20[394]){if(Z20[36][U_2[7][43]][U_2[7][334]][U_2[4] + 1] != undefined){k7V.H0n(5);U_2[9]=Z20[36][U_2[7][43]][U_2[7][334]][k7V.w_c(1,U_2[4])];k7V.d1M(5);Z20[36][U_2[7][43]][U_2[7][334]][k7V.w_c(1,U_2[4])]=Z20[36][U_2[7][43]][U_2[7][334]][U_2[4]];Z20[36][U_2[7][43]][U_2[7][334]][U_2[4]]=U_2[9];}}}else{if(this == Z20[910]){if(Z20[36].spawns[Z20[285] - 1] != undefined){k7V.H0n(0);U_2[1]=Z20[36].spawns[Z20[285] - 1];k7V.H0n(0);Z20[36].spawns[Z20[285] - 1] = U_2[5];Z20[36].spawns[Z20[285]] = U_2[1];Z20[285]--;}}else if(this == Z20[394]){if(Z20[36].spawns[Z20[285] + 1] != undefined){k7V.H0n(5);U_2[9]=Z20[36].spawns[Z20[285] + 1];k7V.H0n(5);Z20[36].spawns[Z20[285] + 1] = U_2[5];Z20[36].spawns[Z20[285]] = U_2[9];Z20[285]++;}}}P_w();N_A(true);}`);

    // disable width rounding to integers
    newSrc = newSrc.replace(r1.split(";")[0] + ";", `${r1.split("=")[0]}=${r1.split("=")[1].split(";")[0].match(/.{7}(?=\))/)};`);

    // disable rectangle position rounding to integers
    for(let i = 0; i < 4; i++) newSrc = newSrc.replace(r2[i].join("="), `${r2[i][0]}=${r2[i][1].match(/.{6}(?=\))/)};`);

    // replace the minimum number of width, height and radius with MIN_VALUE (values lower than 1e-100 are not recommended)
    newSrc = newSrc.replaceAll(`min:1,`, `min:Number.MIN_VALUE,`);
    newSrc = newSrc.replaceAll(r4 ,`function ${r4.split(" ")[1].substring(0,3)}(arg_){return arg_;}`);

    if(src === newSrc) throw "Injection failed!";
    console.log("bonk.io rectangle fix injector run");
    return newSrc;
}

if(!window.bonkCodeInjectors) window.bonkCodeInjectors = [];
window.bonkCodeInjectors.push(bonkCode => {
    try {
        return injector(bonkCode);
    } catch (error) {
        alert(`Whoops! bonk.io rectangle fix was unable to load.`);
        throw error;
    }
});

console.log("bonk.io rectangle fix injector loaded");