Advertisement
Guest User

Untitled

a guest
Nov 17th, 2023
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name Bloxd.io X-ray
  3. // @namespace JonJon565
  4. // @match https://bloxd.io/*
  5. // @grant none
  6. // @version 1.0
  7. // @author JonJon565
  8. // @description X-ray for Bloxd.io
  9. // @run-at document-start
  10. // @icon https://bloxd.io/favicon-32x32.png
  11. // ==/UserScript==
  12.  
  13. (() => {
  14.     const replacementsArr = ['stone', 'stone_andesite', 'stone_diorite', 'messy_stone'];
  15.  
  16.     let URL = null;
  17.  
  18.     function patchNode(node) {
  19.         console.log("Starting Patch For", node.src);
  20.  
  21.         node?.remove();
  22.  
  23.         fetch(node.src)
  24.             .then(res => res.text())
  25.             .then(text => {
  26.                 replacementsArr.forEach(word => {
  27.                     try {
  28.                         const toReplace = `("${word}"),`;
  29.                         const replacement = `${toReplace}transTex: !0,`;
  30.  
  31.                         text = text.replaceAll(toReplace, replacement);
  32.  
  33.                         console.log("Replacement Success!", word, toReplace, replacement);
  34.                     } catch(e) {
  35.                         console.error("Error With Replacement: ", word, e.message);
  36.                     }
  37.                 });
  38.  
  39.                 const newNode = document.createElement('script');
  40.  
  41.                 newNode.innerHTML = text;
  42.  
  43.                 document.body.appendChild(newNode);
  44.             });
  45.     }
  46.  
  47.     new MutationObserver(mutationsList => {
  48.         if(URL === null) {
  49.             const thirdScriptSrc = document.querySelector('body script:nth-of-type(3)')?.src;
  50.  
  51.             if(!thirdScriptSrc) return;
  52.  
  53.             URL = thirdScriptSrc;
  54.         }
  55.  
  56.         mutationsList.forEach(mutationRecord => {
  57.             [...mutationRecord.addedNodes]
  58.                 .filter(node => node.tagName === 'SCRIPT' && node.src.includes(URL))
  59.                 .forEach(node => patchNode(node));
  60.         });
  61.     }).observe(document, { childList: true, subtree: true });
  62. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement