Greasy Fork is available in English.

Bonk.io Left Gravity Mode

Add a left gravity mode to bonk.io. No idea if this is compatible with other extensions and I can't be bothered to test.

  1. // ==UserScript==
  2. // @name Bonk.io Left Gravity Mode
  3. // @version 1.2
  4. // @author Blu ft. Salama ft. MYTH_doglover
  5. // @description Add a left gravity mode to bonk.io. No idea if this is compatible with other extensions and I can't be bothered to test.
  6. // @match https://bonk.io/gameframe-release.html
  7. // @run-at document-start
  8. // @grant GM_xmlhttpRequest
  9. // @license MIT
  10.  
  11. // @namespace https://greatest.deepsurf.us/users/747730
  12. // ==/UserScript==
  13.  
  14. // this userscript is a remix of Salama's Simple injector which is a remix of Blu's VarTOL injector which is a remix of Salama's VTOL injector!
  15. // https://github.com/Salama/bonk-vtol/blob/master/injector.js
  16.  
  17. //Thanks to Salama for help with getting this to work!
  18.  
  19.  
  20. const injectorName = `LeftGravity`;
  21. const errorMsg = `Poops! ${injectorName} was comfortable to toad.
  22. This may be poo to an resizement to Bonkio.com. If so, please don't report this error!
  23. This could also be because you have an extension that is in cahoots with \
  24. ${injectorName}`;
  25.  
  26. function injector(src){
  27. let newSrc = src;
  28. //allow Left Gravity to be selected
  29. newSrc=newSrc.replace('[S9L.C1E(107),S9L.W1E(1130),S9L.C1E(1131),S9L.W1E(1132),',LEFTGRAVITY_MODE);
  30. newSrc=newSrc.replace('P1R[43][P1R[7][551]][S9L.C1E(116)]={lobbyName:S9L.C1E(2093),gameStartName:S9L.C1E(2094),lobbyDescription:S9L.W1E(2095),tutorialTitle:S9L.W1E(2096),tutorialText:S9L.W1E(2097),forceTeams:true,forceTeamCount:2,editorCanTarget:false};', LGMODE_METADATA);
  31.  
  32. //add classic rules to Left Gravity
  33. newSrc=newSrc.replace('if(O7R[0][4][O7R[8][118]] == "b" || O7R[0][4][O7R[8][118]] == "v"', 'if(O7R[0][4][O7R[8][118]] == "b" || O7R[0][4][O7R[8][118]] == "v" || O7R[0][4][O7R[8][118]] == "lg"');
  34. newSrc=newSrc.replace('O7R[0][4][O7R[8][118]] == "b" || O7R[0][4][O7R[8][118]] == "bs"', 'O7R[0][4][O7R[8][118]] == "b" || O7R[0][4][O7R[8][118]] == "bs" || O7R[0][4][O7R[8][118]] == "lg"');
  35.  
  36. //add gravity effect
  37. newSrc=newSrc.replace('"v"){;}',LEFTGRAVITY_GAME);
  38.  
  39. if(src === newSrc) throw "Injection failed!";
  40. console.log(injectorName+" injector run");
  41. return newSrc;
  42. }
  43.  
  44. // Adds LEFTGRAVITY to mode selection button
  45. const LEFTGRAVITY_MODE= `[S9L.C1E(107),S9L.W1E(1130),S9L.C1E(1131),S9L.W1E(1132),"lg",`;
  46. //add LEFTGRAVITY metadata
  47. const LGMODE_METADATA= `P1R[43][P1R[7][551]][S9L.C1E(116)]={lobbyName:S9L.C1E(2093),gameStartName:S9L.C1E(2094),lobbyDescription:S9L.W1E(2095),tutorialTitle:S9L.W1E(2096),tutorialText:S9L.W1E(2097),forceTeams:true,forceTeamCount:2,editorCanTarget:false}; P1R[43][P1R[7][551]]["lg"] = {lobbyName:"Left Gravity",gameStartName:"LEFT GRAVITY",lobbyDescription:"Bonk with left gravity!",tutorialTitle:"Left Gravity Mode",tutorialText:"•Move with the arrow keys\\r\\n•Hold X to make yourself heavier",forceTeams:false,forceTeamCount:null,editorCanTarget:false};`;
  48.  
  49.  
  50. const LEFTGRAVITY_GAME = `"v"){;} if (O7R[0][4][O7R[8][118]] == "lg"){
  51.  
  52. //change gravity function
  53. if(O7R[72][O7R[8][177]]()[O7R[8][40]] != 0){O7R[72][O7R[8][178]](new P1R[2](-20,0));;}
  54.  
  55. }`;
  56. const head = document.getElementsByTagName("head")[0];
  57. head.appendChild = new Proxy(head.appendChild, {
  58. apply: async (target, thisArg, args) => {
  59. if (args[0] && args[0].src.includes("alpha2s.js")) {
  60. console.log("[NoGravity] Fetching alpha2s.js...")
  61. let src = await fetch(args[0].src).then(res => res.text())
  62. let newSrc=injector(src);
  63.  
  64. //if(src === newSrc) throw "Injection failed!";
  65. // Remove the src attribute so it doesn't try to load the original script
  66. args[0].removeAttribute("src");
  67. // Add the new script to the <script>'s contents
  68. args[0].textContent = newSrc;
  69.  
  70. console.log("[LEFT GRAVITY] Patched alpha2s.js")
  71. }
  72. return target.apply(thisArg, args);
  73. }
  74. });
  75. console.log(injectorName+" injector loaded");