iiBuggzZz

Shell Shockers Multicolored Cosshair

Apr 5th, 2022 (edited)
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.44 KB | None | 0 0
  1. // ==UserScript==
  2. // @name         Multicolor Crosshair (RAINBOW EDITION)
  3. // @version      0.1
  4. // @description  Rainbow crosshair in shell shockers! Be the you that you were always meant to be! 🏳️‍🌈
  5. // @match        *://shellshock.io/*
  6. // @author       iiBuggzZz
  7. // @run-at       document-body
  8. // @grant        Math.mod
  9. // @grant        window.extern
  10. // @namespace    https://greasyfork.org/users/815159
  11. // ==/UserScript==
  12.  
  13. (function () {
  14.     function HSVtoRGB(h, s, v) {
  15.         var r, g, b, i, f, p, q, t;
  16.         if (arguments.length === 1) {
  17.             s = h.s, v = h.v, h = h.h;
  18.         }
  19.         i = Math.floor(h * 6);
  20.         f = h * 6 - i;
  21.         p = v * (1 - s);
  22.         q = v * (1 - f * s);
  23.         t = v * (1 - (1 - f) * s);
  24.         switch (i % 6) {
  25.             case 0: r = v, g = t, b = p; break;
  26.             case 1: r = q, g = v, b = p; break;
  27.             case 2: r = p, g = v, b = t; break;
  28.             case 3: r = p, g = q, b = v; break;
  29.             case 4: r = t, g = p, b = v; break;
  30.             case 5: r = v, g = p, b = q; break;
  31.         }
  32.         return {
  33.             r: Math.round(r * 255),
  34.             g: Math.round(g * 255),
  35.             b: Math.round(b * 255)
  36.         };
  37.     }
  38.  
  39.     const colors = [[], [], []];
  40.  
  41.     for (let wl = 0; wl < 100; wl++) {
  42.        const {
  43.            r,
  44.            g,
  45.            b
  46.        } = HSVtoRGB(wl / 100.0 * 0.85, 1.0, 1.0);
  47.  
  48.        colors[0].push(r);
  49.        colors[1].push(g);
  50.        colors[2].push(b);
  51.    }
  52.  
  53.    let crosshairs = [];
  54.    let crosshairsSet = false;
  55.    let colorIdx = 0;
  56.    setInterval(function () {
  57.        if (!crosshairsSet && typeof crosshair1 === "object") {
  58.  
  59.            for (let i = 0; i < 4; i++) {
  60.                crosshairs.push(document.getElementById("crosshair" + i));
  61.            }
  62.            crosshairsSet = true;
  63.        }
  64.  
  65.        if (typeof extern !== "undefined" && extern.inGame) {
  66.            for (let i = 0; i < 4; i++) {
  67.                let ch = crosshairs[i];
  68.                const idx = Math.mod(Math.floor(colorIdx + 30 * i), 100);
  69.                const colorString = `rgb(${colors[0][idx]}, ${colors[1][idx]}, ${colors[2][idx]})`;
  70.                ch.style.backgroundColor = colorString;
  71.                ch.style.color = colorString;
  72.  
  73.            }
  74.  
  75.            colorIdx += 0.89;
  76.            if (colorIdx >= 100) {
  77.                 colorIdx = 0;
  78.             }
  79.         }
  80.  
  81.     }, 33);
  82. }())
Add Comment
Please, Sign In to add comment