OFans.party IPFS gateway replacer

Replaces the currently-broken IPFS gateway used by ofans.party with a different, working one.

2021-04-13 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         OFans.party IPFS gateway replacer
// @namespace    https://greasyfork.org/users/390979-parliament
// @description  Replaces the currently-broken IPFS gateway used by ofans.party with a different, working one.
// @version      0.1
// @author       parliament
// @match        https://ofans.party/
// @run-at       document-idle
// ==/UserScript==

'use strict';

function replaceAllUris() {
    let links = document.getElementsByTagName("a");
    let images = document.getElementsByTagName("img");

    for (let link of links) {
        let uri = link.getAttribute("href");
        let fixedUri = uri.replace(/ipfs\.greyh\.at/, "ninetailed.ninja");
        link.setAttribute("href", fixedUri);
    }

    for (let image of images) {
        let uri = image.getAttribute("src");
        let fixedUri = uri.replace(/ipfs\.greyh\.at/, "ninetailed.ninja");
        image.setAttribute("src", fixedUri);

        console.log("Old URI: " + uri);
        console.log("New URI: " + fixedUri);
    }
}

var lastTimeout;
let observer = new MutationObserver((changes, observer) => {
    if (lastTimeout !== undefined) {
        window.clearTimeout(lastTimeout);
    }

    lastTimeout = window.setTimeout(replaceAllUris, 200);
});
observer.observe(document, {childList: true, subtree: true});