OFans.party IPFS gateway replacer

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

Versione datata 13/04/2021. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==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});