E-Hitomi

Adds a button to E-Hentai to open a supported gallery on Hitomi.la

Versión del día 26/6/2024. Echa un vistazo a la versión más reciente.

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

Necesitarás instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Necesitará instalar una extensión como Tampermonkey para instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

// ==UserScript==
// @name         E-Hitomi
// @namespace    http://linktr.ee/GanbatGAN
// @version      2.0
// @description  Adds a button to E-Hentai to open a supported gallery on Hitomi.la
// @author       Ganbat
// @match        http*://exhentai.org/g/*
// @match        http*://e-hentai.org/g/*
// @match        http*://*.e-hentai.org/g/*
// @grant        GM.xmlHttpRequest
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4gQaCi4QRludjAAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAADiUlEQVRo3u2aT2gcVRzHP+/NvOyk3XT/NHY3kI3akFqKhqIg9BCpf/FSaLW1ioeCIgha8CR68KD05kHwIPZS8CSiaEXIRRRUCGrtH6sVSmi0Tbpt1SSb7SaZ3Zmd5yG2dJPZ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ORK5CYII=
// ==/UserScript==

const pathsarray = window.location.pathname.split('/');
const verbose = 0;
let mricon;
if ( window.location.hostname == "exhentai.org" ) {
    mricon = "exhentai.org/img";
} else {
    mricon = "ehgt.org/g";
}

function hitomiLink(g){
    const siteContent = document.getElementById("gd5");
    let hitLinkP = document.createElement('p');
    hitLinkP.setAttribute('class', 'g2');
    hitLinkP.innerHTML = `<img src="https://${mricon}/mr.gif"> <a id="hitomilink" href="https://hitomi.la${g["galleryurl"]}">Open on Himtomi.la</a>`
    siteContent.appendChild(hitLinkP);
};

(()=>{
    // Note: This JS file contains nothing but a single variable containing JSON, a confusing choice on behalf of Hitomi.
    // We don't want to eval this script. Instead, we strip the (minor) JS from it and parse the JSON to get what we need.
    // Hopefully, this won't run afoul of Greasyfork's rules, but if it does, we can always change this to a HEAD request,
    // change the resultant link back to the E-Hentai redirect and remove the 'blocked' detection entirely.
    GM.xmlHttpRequest({
        method: "GET",
        url: "https://ltn.hitomi.la/galleries/"+pathsarray[2]+".js",
        onload: function(response) {
            if (verbose) console.log("Hitomi response status: " + String(response.status));
            if (response.status != 200) return;
            const hitGalInfo = JSON.parse(response.responseText.slice(18));
            if (verbose) console.log(hitGalInfo);
            if (hitGalInfo["blocked"]) return;
            hitomiLink(hitGalInfo);
        }
    });
})();