Advertisement
iiBuggzZz

Shell Shockers Mod Panel Script

Apr 5th, 2022
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 10.13 KB | None | 0 0
  1. // ==UserScript==
  2. // @name         Mod Panel for Shell Shockers
  3. // @version      0.1
  4. // @author       iiBuggzZz
  5. // @description  Feat. RAINBOW CROSSHAIR, FOG MOD, SKIN MOD, SKY COLOR MOD
  6. // @match        *://shellshock.io/*
  7. // @namespace    https://greasyfork.org/users/815159
  8. // @run-at       document-start
  9. // @grant        none
  10. // ==/UserScript==
  11. (function () {
  12.  
  13.     const shellMod = {
  14.         interval: null,
  15.         gui: null,
  16.         storedData: {
  17.             scene: null,
  18.             camera: null,
  19.             reticle: null,
  20.             rainbowCrosshairEnabled: false,
  21.             colorDelta: 0.89,
  22.             colorIdx: 0,
  23.             colors: [[], [], []],
  24.             skyColor: "#FFFFFF",
  25.             skyBoxAlpha: 1,
  26.             useSkyColor: false,
  27.             fogDensity: 0.01,
  28.             fogColor: "#FFFFFF",
  29.         },
  30.         replacements: {
  31.             unlockSkins: {
  32.                 regex: /inventory\[[A-z]\].id===[A-z].id\)return!0;return!1/,
  33.                 replace: "rep = `${match[0]}||true`"
  34.             },
  35.             camera: {
  36.                 regex: /.push\(([A-z])\),\w.maxZ=100/,
  37.                 replace: "rep = `${match[0]},window.modHelper.camera=${match[1]}`"
  38.             },
  39.             scene: {
  40.                 regex: /([A-z][A-z])\.fogDensity=.01\);/,
  41.                 replace: "rep = `${match[0]}window.modHelper.scene=${match[1]};`"
  42.             },
  43.             crosshairs: {
  44.                 regex: /document.getElementById\("dotReticle"\)/,
  45.                 replace: "rep = `${match[0]};window.modHelper.reticle=this;${atob('ZG9jdW1lbnQudGl0bGU=')}=atob('U2hlbGwgU2hvY2tlcnMgfCBNb2RkZWQgYnkgQTMgfCBieSBCbHVlIFdpemFyZCBEaWdpdGFs');`"
  46.             }
  47.         },
  48.         updateSky: function () {
  49.             if (!this.storedData.scene) return;
  50.             let skyMesh = this.storedData.scene.getMeshByID("skyBox");
  51.             if (skyMesh) {
  52.                 if (!skyMesh.oldTexture) skyMesh.oldTexture = skyMesh.material.reflectionTexture;
  53.  
  54.                 if (this.storedData.useSkyColor) {
  55.                     skyMesh.material.emissiveColor.set(...this.hexToRgb(this.storedData.skyColor));
  56.                     skyMesh.material.reflectionTexture = null;
  57.                     skyMesh.material.alpha = this.storedData.skyBoxAlpha;
  58.  
  59.                 } else {
  60.                     skyMesh.material.emissiveColor.set(...this.hexToRgb("#000000"));
  61.                     skyMesh.material.reflectionTexture = skyMesh.oldTexture;
  62.                     skyMesh.material.alpha = 1;
  63.  
  64.                 }
  65.             }
  66.         },
  67.         updateFog: function () {
  68.             if (!this.storedData.scene) return;
  69.  
  70.             this.storedData.scene.fogColor.set(...this.hexToRgb(this.storedData.fogColor));
  71.             this.storedData.scene.fogDensity = this.storedData.fogDensity;
  72.         },
  73.         hexToRgb: function (hex) {
  74.             let result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
  75.             return result ? [parseInt(result[1], 16) / 255, parseInt(result[2], 16) / 255, parseInt(result[3], 16) / 255] : [];
  76.         },
  77.         doHooks: function () {
  78.             window.XMLHttpRequest = class extends window.XMLHttpRequest {
  79.                 constructor() {
  80.                     super(...arguments);
  81.                 }
  82.                 open() {
  83.                     if (arguments[1] && arguments[1].includes("shellshock.js")) this.scriptMatch = true;
  84.  
  85.                     super.open(...arguments);
  86.                 }
  87.                 get response() {
  88.  
  89.                     if (this.scriptMatch) {
  90.                         let responseText = super.response;
  91.  
  92.  
  93.                         let rep;
  94.                         for (let key of Object.keys(shellMod.replacements)) {
  95.  
  96.                             let replacement = shellMod.replacements[key];
  97.                             let match = responseText.match(replacement.regex);
  98.                             if (match) responseText = responseText.replace(match[0], eval(replacement.replace));
  99.                         }
  100.  
  101.                         return responseText;
  102.                     }
  103.                     return super.response;
  104.                 }
  105.             };
  106.  
  107.         },
  108.         createGUI: function () {
  109.             this.gui = new guify({
  110.                 title: "<b>Mod Panel</b>",
  111.                 theme: "dark",
  112.                 align: "left",
  113.                 width: 300,
  114.                 barMode: "none",
  115.                 panelMode: "none",
  116.                 opacity: 0.90,
  117.                 root: window.container,
  118.                 open: true
  119.             });
  120.  
  121.             this.gui.Register([{
  122.                 type: "folder",
  123.                 label: "Fog Controls",
  124.                 open: false
  125.             }, {
  126.                 type: "folder",
  127.                 label: "Sky Color",
  128.                 open: false
  129.             }, {
  130.                 type: "folder",
  131.                 label: "Rainbow Crosshair",
  132.                 open: false
  133.             }]);
  134.  
  135.             this.gui.Register([{
  136.                 type: "checkbox",
  137.                 label: "Use Sky Color:",
  138.                 object: this.storedData,
  139.                 property: "useSkyColor",
  140.                 onChange: () => this.updateSky()
  141.             }, {
  142.                 type: "color",
  143.                 label: "Sky Color:",
  144.                 format: "hexColor",
  145.                 object: this.storedData,
  146.                 property: "skyColor",
  147.                 onChange: () => this.updateSky()
  148.             }, {
  149.                 type: "range",
  150.                 label: "Alpha:",
  151.                 min: 0, max: 1,
  152.                 object: this.storedData,
  153.                 property: "skyBoxAlpha",
  154.                 onChange: () => this.updateSky()
  155.             }], {
  156.                 folder: "Sky Color"
  157.             });
  158.  
  159.             this.gui.Register([{
  160.                 type: "range",
  161.                 label: "Fog Density:",
  162.                 min: 0, max: 1,
  163.                 object: this.storedData,
  164.                 property: "fogDensity",
  165.                 onChange: () => this.updateFog()
  166.             }, {
  167.                 type: "color",
  168.                 label: "Fog Color:",
  169.                 format: "hexColor",
  170.                 object: this.storedData,
  171.                 property: "fogColor",
  172.                 onChange: () => this.updateFog()
  173.             }], {
  174.                 folder: "Fog Controls"
  175.             });
  176.  
  177.             this.gui.Register([{
  178.                 type: "checkbox",
  179.                 label: "Use Rainbow Crosshair:",
  180.                 object: this.storedData,
  181.                 property: "rainbowCrosshairEnabled",
  182.             }, {
  183.                 type: "range",
  184.                 label: "Delta:",
  185.                 min: 0, max: 2.5,
  186.                 object: this.storedData,
  187.                 property: "colorDelta",
  188.             }], {
  189.                 folder: "Rainbow Crosshair"
  190.             });
  191.  
  192.             this.gui.Register({
  193.                 type: "title",
  194.                 label: "Created by iiBuggzZz Aka (Aiden)"
  195.             }).container.align = "center";
  196.  
  197.             this.gui.panel.menuButton.style.opacity = 0.3;
  198.         },
  199.         loadMod: function () {
  200.             const addScript = function () {
  201.                 let script = document.createElement('script');
  202.                 script.onload = function () { shellMod.createGUI() };
  203.                 script.src = "https://unpkg.com/guify@0.12.0/lib/guify.min.js";
  204.                 document.body.appendChild(script);
  205.             }
  206.             document.body ? addScript() : document.addEventListener("DOMContentLoaded", addScript);
  207.  
  208.             this.doHooks();
  209.  
  210.             function HSVtoRGB(h, s, v) {
  211.                 var r, g, b, i, f, p, q, t;
  212.                 i = Math.floor(h * 6);
  213.                 f = h * 6 - i;
  214.                 p = v * (1 - s);
  215.                 q = v * (1 - f * s);
  216.                 t = v * (1 - (1 - f) * s);
  217.                 switch (i % 6) {
  218.                     case 0: r = v, g = t, b = p; break;
  219.                     case 1: r = q, g = v, b = p; break;
  220.                     case 2: r = p, g = v, b = t; break;
  221.                     case 3: r = p, g = q, b = v; break;
  222.                     case 4: r = t, g = p, b = v; break;
  223.                     case 5: r = v, g = p, b = q; break;
  224.                 }
  225.                 return { r: Math.round(r * 255), g: Math.round(g * 255), b: Math.round(b * 255) };
  226.             }
  227.  
  228.             for (let wl = 0; wl < 100; wl++) {
  229.                const { r, g, b } = HSVtoRGB(wl / 100.0 * 0.85, 1.0, 1.0);
  230.  
  231.                this.storedData.colors[0].push(r);
  232.                this.storedData.colors[1].push(g);
  233.                this.storedData.colors[2].push(b);
  234.            }
  235.  
  236.            if (!this.interval) {
  237.                this.interval = setInterval(function () {
  238.                    if (shellMod.storedData.rainbowCrosshairEnabled && typeof extern !== "undefined" && extern.inGame) {
  239.                        for (let i = 0; i < 4; i++) {
  240.  
  241.                            let ch = shellMod.storedData.reticle.crosshairs[i];
  242.                            const idx = Math.mod(Math.floor(shellMod.storedData.colorIdx + 30 * i), 100);
  243.  
  244.                            const rgbString = `rgb(${shellMod.storedData.colors[0][idx]}, ${shellMod.storedData.colors[1][idx]}, ${shellMod.storedData.colors[2][idx]})`;
  245.                            ch.style.backgroundColor = rgbString;
  246.                            ch.style.color = rgbString;
  247.  
  248.                        }
  249.  
  250.                        shellMod.storedData.colorIdx += shellMod.storedData.colorDelta;
  251.                        if (shellMod.storedData.colorIdx >= 100) shellMod.storedData.colorIdx = 0;
  252.                     }
  253.                     if (typeof extern !== "undefined" && typeof vueApp !== "undefined") {
  254.                        if (!vueApp.isUpgraded || !extern.account.isSubscriber) { vueApp.setAccountUpgraded(true, ""); extern.account.isSubscriber = true; }
  255.                     }
  256.                 }, 33);
  257.             }
  258.         }
  259.  
  260.     }
  261.  
  262.     window.modHelper = {
  263.         set scene(c) { shellMod.storedData.scene = c },
  264.         set camera(c) { shellMod.storedData.camera = c },
  265.         set reticle(c) { shellMod.storedData.reticle = c }
  266.     }
  267.  
  268.     shellMod.loadMod();
  269. }())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement