Greasy Fork is available in English.

Universal Domain Redirect

did someone change their domain but a imbed is still using the old one \n not anymore automaticaly change domains to fix this \n originaly made because aniwatch stoped working

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, Greasemonkey alebo Violentmonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey alebo Userscripts.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie správcu používateľských skriptov.

(Už mám správcu používateľských skriptov, nechajte ma ho nainštalovať!)

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

(Už mám správcu používateľských štýlov, nechajte ma ho nainštalovať!)

// ==UserScript==
// @name         Universal Domain Redirect
// @namespace   Violentmonkey Scripts
// @version     1.2
// @description  did someone change their domain but a imbed is still using the old one \n not anymore automaticaly change domains to fix this \n originaly made because aniwatch stoped working
// @author       dindiner
// @match        *://*/*
// @exclude      *://*youtube*/*
// @run-at       document-start
// @grant        unsafeWindow
// @license MIT
// ==/UserScript==
(function(){
    'use strict';
  	const win=(unsafeWindow||window);
    const chnglst={
        // TLD-style rule
        //"megacloud": { ".blog": ".tv" },
        // Full domain swap (root + subdomains)
        "megacloud.blog": "megacloud.tv"
    };
    const transformUrl=(url)=>{
        try{
            const u=new URL(url);
            let host=u.hostname;
            for(const key in chnglst){
                const val=chnglst[key];
                if(typeof val==="string"){
                    if(host===key||host.endsWith("."+key)){
                        const prefix=host===key?"":host.replace("."+key,"");
                        host=prefix?`${prefix}.${val}`:val;
                    }
                }else if(typeof val==="object"){
                    for(const from in val){
                        const to=val[from];
                        if(host===key+from||host.endsWith("."+key+from)){
                            const prefix=host===key+from?"":host.replace("."+key+from,"");
                            host=prefix?`${prefix}.${key}${to}`:`${key}${to}`;
                        }
                    }
                }
            }
            u.hostname=host;
            return u.toString();
        }catch(e){
            return url;
        }
    };
    const redirected=transformUrl(win.location.href);
    if(redirected!==win.location.href){
        win.location.replace(redirected);
        return;
    }
    const fixIframes=()=>{
        document.querySelectorAll('iframe').forEach(iframe=>{
            if(iframe.src){
                const updated=transformUrl(iframe.src);
                if(updated!==iframe.src)iframe.src=updated;
            }
        });
    };
    const originalFetch=win.fetch;
    win.fetch=function(input,init){
        try{
            let url=(typeof input==="string")?input:input.url;
            const newUrl=transformUrl(url);
            if(typeof input==="string"){
                input=newUrl;
            }else{
                input=new Request(newUrl,input);
            }
        } catch(e){}
        return originalFetch.call(this,input,init);
    };
    const originalOpen=XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open=function(method,url,...rest){
        try{
            url=transformUrl(url);
        }catch(e){}
        return originalOpen.call(this,method,url,...rest);
    };
    const observer=new MutationObserver(fixIframes);
    const init=()=>{
        fixIframes();
        observer.observe(document.documentElement,{childList:true,subtree:true});
    };
    if (document.readyState==='loading'){
        document.addEventListener('DOMContentLoaded',init);
    }else{
        init();
    }
})();