SimpCity Re-re-direct

Bypass the new external link warning on SimpCity

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

// ==UserScript==
// @name        SimpCity Re-re-direct
// @namespace   https://github.com/chuckmingus
// @version     1.1.2
// @description Bypass the new external link warning on SimpCity
// @author      chuckmingus
// @icon        https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/cobalt.png
// @license     MIT
// @match       https://simpcity.cr/*
// @match       https://simpcity.su/*
// @grant       none
// @run-at      document-start
// ==/UserScript==

(function () {
  "use strict";
 
  // fallback for when we are already on a redirect page
  if (window.location.href.includes('/redirect/')) {
    const target = document.querySelector(".simpLinkProxy-targetLink").href;
 
    window.location.replace(target)
  }
 
  // otherwise try to modify links as they are added to the page
 
  function decodeTarget(str) {
    try {
 
      const normalized = str.replace(/-/g, '+').replace(/_/g, '/');
      return atob(normalized);
    } catch (e) {
      console.error("[SimpCity Re-re-direct] Failed to decode base64:", str, e);
      return null;
    }
  }
 
  function processLinks() {
    const links = document.querySelectorAll('a[href*="/redirect/?to="]:not([data-bypassed])');
 
    links.forEach(link => {
      link.dataset.bypassed = "true";
      try {
        const url = new URL(link.href, window.location.origin);
        let targetUrl = url.searchParams.get("to");
        const mode = url.searchParams.get("m");
 
        if (targetUrl && mode === "b64") {
          targetUrl = decodeTarget(targetUrl);
        }
 
        if (targetUrl) {
          link.href = targetUrl;
          link.removeAttribute('data-proxy-handler');
          link.removeAttribute('data-blank-handler');
          link.removeAttribute('data-proxy-href');
        }
      } catch (e) {
        // Silently fail for invalid URLs
      }
    });
  }
 
  // keep watch for loaded links
  const observer = new MutationObserver(() => {
    processLinks();
  });
 
  observer.observe(document.documentElement, {
    childList: true,
    subtree: true
  });
 
  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', processLinks);
  } else {
    processLinks();
  }
 
})();