Redirector

Redirect Instagram to imginn.com and Reddit to redlib.catsearch.com; add ?x=1 or #x to skip redirect

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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 यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Redirector
// @namespace    https://example.org/redirects
// @version      1.2
// @description  Redirect Instagram to imginn.com and Reddit to redlib.catsearch.com; add ?x=1 or #x to skip redirect
// @match        *://*.instagram.com/*
// @match        *://instagram.com/*
// @match        *://*.reddit.com/*
// @match        *://reddit.com/*
// @run-at       document-start
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
  const url = new URL(location.href);
  const bypass = url.searchParams.get('x') === '1' || location.hash.includes('#x') || location.hash === 'x';
  if (bypass) return;

  const redirects = [
    { hosts: ['instagram.com', 'www.instagram.com'], target: 'imginn.com' },
    { hosts: ['reddit.com', 'www.reddit.com'], target: 'redlib.catsarch.com' },
  ];

  const host = location.hostname.toLowerCase();
  for (const r of redirects) {
    if (r.hosts.includes(host) && host !== r.target) {
      const newUrl = location.protocol + '//' + r.target + location.pathname + location.search + location.hash;
      location.replace(newUrl);
      break;
    }
  }
})();