jtpotjgfadsj

📅 2025-09-22T12:33:58.558Z
👁️ 48 katselukertaa
🔓 Julkinen


(function() {
    // --- Navigoi ensin /work ja sitten /home pienen viiveen kanssa ---
    window.history.pushState(null, '', '/work'); 
    window.dispatchEvent(new PopStateEvent('popstate')); 
  
    setTimeout(() => {
      window.history.pushState(null, '', '/home'); 
      window.dispatchEvent(new PopStateEvent('popstate')); 
      console.log("[Navigation] Käytiin /work, nyt pysytään /home");
    }, 100); 
  
    // --- LOADING OVERLAY ---
    const overlay = document.createElement('div');
    overlay.style.position = 'fixed';
    overlay.style.top = '0';
    overlay.style.left = '0';
    overlay.style.width = '100%';
    overlay.style.height = '100%';
    overlay.style.backgroundColor = '#000000';
    overlay.style.display = 'flex';
    overlay.style.alignItems = 'center';
    overlay.style.justifyContent = 'center';
    overlay.style.flexDirection = 'column';
    overlay.style.zIndex = '1000000';
    overlay.style.transition = 'opacity 1s';
    document.body.appendChild(overlay);
  
    // --- LOADING CONTAINER (GIF + SPINNER/SYMBOL) ---
    const loadingContainer = document.createElement('div');
    loadingContainer.style.display = 'flex';
    loadingContainer.style.flexDirection = 'column';
    loadingContainer.style.alignItems = 'center';
    loadingContainer.style.justifyContent = 'center';
    loadingContainer.style.position = 'relative';
    loadingContainer.style.marginTop = '-100px'; // Move up 100px
    overlay.appendChild(loadingContainer);
  
    // --- BIG GIF ---
    const gif = document.createElement('img');
    gif.src = 'https://pixeldrain.com/api/file/YwEMSZE3?download';
    gif.style.height = '600px';
    gif.style.position = 'relative';
    gif.style.top = '50px'; // nudge down a bit because of transparency
    loadingContainer.appendChild(gif);
  
    // --- SPINNER ---
    const spinner = document.createElement('div');
    spinner.style.width = '80px';
    spinner.style.height = '80px';
    spinner.style.border = '10px solid white';
    spinner.style.borderTop = '10px solid transparent';
    spinner.style.borderRadius = '50%';
    spinner.style.animation = 'spin 1s linear infinite';
    spinner.style.marginTop = '20px'; // space below GIF
    loadingContainer.appendChild(spinner);
  
    // SPINNER KEYFRAMES
    const style = document.createElement('style');
    style.innerHTML = `
      @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
      @keyframes scaleRotateFade {
        0% { transform: scale(1) rotate(0deg); opacity:1; }
        50% { transform: scale(0.5) rotate(180deg); opacity:0.5; }
        100% { transform: scale(1) rotate(360deg); opacity:1; }
      }
    `;
    document.head.appendChild(style);
  
    // --- AUDIO ---
    const sound1 = new Audio('https://pixeldrain.com/api/file/4UtuuyL8?download');
    const sound2 = new Audio('https://pixeldrain.com/api/file/zHWo1u6V?download');
    sound1.play();
  
    // --- REQUEST CAPTURE LOGIIKKA ---
    let lastRequest = null; 
    let captureSuccess = false;
  
    function formatFetch(url, options = {}) {
      return `fetch("${url}", ${JSON.stringify(options, null, 2)});`;
    }
  
    function decodeJWT(token) {
      try {
        const payload = JSON.parse(atob(token.split(".")[1]));
        if (payload.exp) {
          const expDate = new Date(payload.exp * 1000);
          console.log("🔑 Token exp:", payload.exp, "=>", expDate.toString());
        } else console.log("Tokenissa ei ole exp-kenttää");
      } catch (e) {
        console.warn("Virheellinen JWT:", e);
      }
    }
  
    function captureRequest(url, options) {
      if (url.includes("myWorkOffers")) {
        lastRequest = { url, options };
        captureSuccess = true;
        console.log("==== Kaapattu myWorkOffers-pyyntö ====");
        console.log(formatFetch(url, options));
        if (options.headers) {
          for (let key in options.headers) {
            if (key.toLowerCase() === "authorization") {
              const bearer = options.headers[key].split(" ")[1];
              decodeJWT(bearer);
            }
          }
        }
      }
    }
  
    const origFetch = window.fetch;
    window.fetch = async function(url, options = {}) {
      captureRequest(url, options);
      return origFetch.apply(this, arguments);
    };
  
    const origOpen = XMLHttpRequest.prototype.open;
    const origSend = XMLHttpRequest.prototype.send;
    const origSetRequestHeader = XMLHttpRequest.prototype.setRequestHeader;
  
    XMLHttpRequest.prototype.open = function(method, url) {
      this._method = method;
      this._url = url;
      this._headers = {};
      return origOpen.apply(this, arguments);
    };
  
    XMLHttpRequest.prototype.setRequestHeader = function(header, value) {
      this._headers[header] = value;
      return origSetRequestHeader.apply(this, arguments);
    };
  
    XMLHttpRequest.prototype.send = function(body) {
      if (this._url && this._url.includes("myWorkOffers")) {
        let options = { method: this._method, headers: this._headers, body: body || null };
        captureRequest(this._url, options);
      }
      return origSend.apply(this, arguments);
    };
  
    // --- WAIT MINIMUM 2 SECONDS, THEN SPINNER TO ICON WITH ANIMATION ---
    setTimeout(() => {
      if(captureSuccess) {
        sound2.play();
        spinner.style.animation = '';
        spinner.innerText = '✅';
      } else {
        // STOP SOUND2 AND ALERT ERROR, KEEP OVERLAY
        sound2.pause();
        alert("⚠️ Kaappaaminen epäonnistui: myWorkOffers-pyyntöä ei löytynyt");
        spinner.style.animation = '';
        spinner.innerText = '❌';
      }
  
      spinner.style.fontSize = '60px';
      spinner.style.color = 'white';
      spinner.style.display = 'flex';
      spinner.style.alignItems = 'center';
      spinner.style.justifyContent = 'center';
      spinner.style.border = 'none';
      spinner.style.borderRadius = '0';
      spinner.style.width = '100px';
      spinner.style.height = '100px';
      spinner.style.animation = 'scaleRotateFade 1s ease-in-out forwards';
  
      if(captureSuccess) {
        setTimeout(() => {
          overlay.style.opacity = '0';
          setTimeout(() => overlay.remove(), 1000);
  
          // --- START HUE SHIFT AFTER LOADING SCREEN ---
          let hue = 0;
          function animateHue() {
            hue += 0.2;
            document.body.style.filter = `hue-rotate(${hue}deg)`;
            requestAnimationFrame(animateHue);
          }
          requestAnimationFrame(animateHue);
        }, 2000);
      }
  
    }, 2000);
  
    // --- NAVBAR ---
    const navbar = document.createElement('div');
    navbar.style.position = 'absolute'; 
    navbar.style.top = '0'; 
    navbar.style.left = '0';
    navbar.style.height = '80px'; 
    navbar.style.width = '50%'; 
    navbar.style.backgroundColor = '#FFFFFF'; 
    navbar.style.zIndex = '9999';
    navbar.style.display = 'flex';
    navbar.style.alignItems = 'center';
    navbar.style.justifyContent = 'flex-start'; 
    navbar.style.paddingLeft = '10px';
    navbar.style.color = 'black'; 
    document.body.appendChild(navbar);
  
    const logo = document.createElement('img');
    logo.src = 'https://pixeldrain.com/api/file/YwEMSZE3?download';
    logo.style.height = '190px';
    logo.style.cursor = 'pointer';
    logo.style.display = 'block';
    logo.style.marginRight = '10px';
    logo.style.position = 'relative';
    logo.style.zIndex = '1';
    navbar.appendChild(logo);
    logo.addEventListener('click', () => {
      window.history.pushState(null, '', '/home');
      window.dispatchEvent(new PopStateEvent('popstate'));
      console.log("[Navigation] Logo klikattu -> navigoidaan /home");
    });
  
    // --- KEYBINDS ---
    document.addEventListener('keydown', e => {
      if (e.key === '1') { window.history.pushState(null, '', '/home'); window.dispatchEvent(new PopStateEvent('popstate')); }
      if (e.key === '2') { window.history.pushState(null, '', '/calendar'); window.dispatchEvent(new PopStateEvent('popstate')); }
      if (e.key === '3') { window.history.pushState(null, '', '/work'); window.dispatchEvent(new PopStateEvent('popstate')); }
      if (e.key === '4') { window.history.pushState(null, '', '/profile'); window.dispatchEvent(new PopStateEvent('popstate')); }
  
      if (e.key === "Enter" && lastRequest) {
        console.log("▶️ Ajetaan viimeisin pyyntö uudestaan...");
        origFetch(lastRequest.url, lastRequest.options)
          .then(r => r.clone().text())
          .then(txt => {
            console.log("==== Uusinta-ajon vastaus (text) ====");
            console.log(txt);
            try { console.log("==== Uusinta-ajon vastaus (JSON) ===="); console.log(JSON.parse(txt)); } catch {}
          })
          .catch(err => console.error("Uusinta epäonnistui:", err));
      }
    });
  
    console.log("[Logger] Script käynnistetty. Keybinds 1-4, ENTER to replay fetch.");
  })();