iiBuggzZz

Shell Shockers FOV Changer

Apr 5th, 2022 (edited)
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.15 KB | None | 0 0
  1. // ==UserScript==
  2. // @name         Change FOV in Shell Shockers!
  3. // @version      0.1
  4. // @description  Implemented slider to change fov in shell shockers!
  5. // @match        *://shellshock.io/*
  6. // @author       iiBuggzZz
  7. // @run-at       document-start
  8. // @grant        unsafeWindow
  9. // @namespace    https://greasyfork.org/users/815159
  10. // ==/UserScript==
  11.  
  12. (function () {
  13.     const degToRad = (deg) => deg * (Math.PI / 180);
  14.     let fovToRadian = 1.25;
  15.  
  16.     unsafeWindow.fixCamera = function (camera) {
  17.         Object.defineProperty(camera, "fov", {
  18.             get: () => fovToRadian || 1.25
  19.         });
  20.     }
  21.     unsafeWindow.resetFov = function () {
  22.         fovToRadian = 1.25;
  23.         display.innerText = "71.62\u00B0";
  24.         slider.value = "71.62\u00B0";
  25.     }
  26.     unsafeWindow.XMLHttpRequest = class extends unsafeWindow.XMLHttpRequest {
  27.         constructor() {
  28.             super(...arguments);
  29.         }
  30.         open() {
  31.             if (arguments[1] && arguments[1].includes("src/shellshock.js")) {
  32.                this.scriptMatch = true;
  33.             }
  34.  
  35.             super.open(...arguments);
  36.         }
  37.         get response() {
  38.  
  39.             if (this.scriptMatch) {
  40.                 let responseText = super.response;
  41.  
  42.                 let match = responseText.match(/.push\(([A-z])\),\w.maxZ=100/);
  43.                 if (match) responseText = responseText.replace(match[0], match[0] + `,window.fixCamera(${match[1]})`);
  44.                 return responseText;
  45.             }
  46.             return super.response;
  47.         }
  48.     };
  49.  
  50.  
  51.     let html = [`<style>.slidecontainer{width:100%}.slider{-webkit-appearance:none;width:100%;height:15px;border-radius:5px;background:#d3d3d3;outline:0;opacity:.7;padding:5px;-webkit-transition:.2s;transition:opacity .2s}.slider:hover{opacity:1}.slider::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:20px;height:20px;border-radius:50%;background:#04aa6d;cursor:pointer}.slider::-moz-range-thumb{width:25px;height:25px;border-radius:50%;background:#04aa6d;cursor:pointer}</style>`,
  52.     `<div class="slidecontainer"><p>FOV: <span id="fovDisplay"></span></p><input type="range" min="1" max="179.9" step="0.01" value="71.62" class="slider" id="fovSlider"></div>`,
  53.     `<div class="btn-container"><button id='resetBtn' onclick='window.resetFov()' class="ss_button btn_small btn_pink bevel_yolk"><center>Reset FOV</center></button></div>`].join();
  54.  
  55.     let display, slider;
  56.     let interval = setInterval(function () {
  57.         let pauseButtons = document.getElementById("pauseButtons");
  58.         if (pauseButtons) {
  59.             clearInterval(interval);
  60.             let fovDiv = document.createElement("div");
  61.             fovDiv.innerHTML = '<br>' + html;
  62.             pauseButtons.appendChild(fovDiv);
  63.  
  64.  
  65.             display = document.getElementById("fovDisplay");
  66.             slider = document.getElementById("fovSlider");
  67.             display.innerText = "71.62\u00B0";
  68.             slider.oninput = function () {
  69.                 let newFov = parseFloat(this.value);
  70.                 display.innerText = newFov + "\u00B0";
  71.                 fovToRadian = degToRad(newFov);
  72.             }
  73.         }
  74.  
  75.     }, 1000);
  76. }())
Add Comment
Please, Sign In to add comment