Forcibly Inject

If the injector doesn't inject, reloads the page.

  1. // ==UserScript==
  2. // @name Forcibly Inject
  3. // @namespace left paren
  4. // @match https://bonk.io/gameframe-release.html
  5. // @run-at document-start
  6. // @grant none
  7. // @version 1.1
  8. // @license Unlicense
  9. // @author left paren
  10. // @description If the injector doesn't inject, reloads the page.
  11. // ==/UserScript==
  12.  
  13. success = false
  14.  
  15. function injector(src){
  16. success = true
  17. return src;
  18. }
  19.  
  20. // Compatibility with Excigma's code injector userscript
  21. if(!window.bonkCodeInjectors) window.bonkCodeInjectors = [];
  22. window.bonkCodeInjectors.push(bonkCode => {
  23. try {
  24. return injector(bonkCode);
  25. } catch (error) {
  26. alert("Forcibly Inject failed");
  27. throw error;
  28. }
  29. });
  30.  
  31. var observer = new MutationObserver(function(mutations) {
  32. if (document.getElementById("bonkiocontainer").style.opacity != 1) return
  33. if (success) {
  34. observer.disconnect()
  35. } else {
  36. window.location.reload()
  37. }
  38. });
  39.  
  40. observer.observe(document.getElementById("bonkiocontainer"), {
  41. attributes: true
  42. });
  43.  
  44. console.log("Forcibly Inject loaded");