E-Hentai <-> ExHentai

Links between E-Hentai and ExHentai page, and also links user to ExHentai automatically if gallery is "removed"

Versión del día 13/02/2017. Echa un vistazo a la versión más reciente.

// ==UserScript==
// @name           E-Hentai <-> ExHentai
// @description    Links between E-Hentai and ExHentai page, and also links user to ExHentai automatically if gallery is "removed"
// @namespace      https://greasyfork.org/en/scripts/24342-e-hentai-exhentai
// @version        1.41
// @icon           https://e-hentai.org/favicon.ico
// @include        http*://e-hentai.org/*
// @include        https://upload.e-hentai.org/*
// @include        https://exhentai.org/*
// @require        https://code.jquery.com/jquery-3.1.1.min.js
// @author         Resuha
// @grant          none
// ==/UserScript==

//Ver 1.41 minor bug in code
//Ver 1.40 made the script work with the new e-hentai URL
//Ver 1.31 removed the blinking linker, seems like it leads to crash

$(document).ready(function () {
    if (document.title == 'Gallery Not Available - E-Hentai Galleries')
    {
        document.location.href = 'https://exhentai.org' + parse_gallery_identifier();
    } else {
        var link;
        var targetWebsite;
        if (document.location.href.indexOf('exhentai') != - 1) {
            link = 'https://e-hentai.org' + parse_gallery_identifier();
            targetWebsite = 'E-Hentai';
        } else {
            link = 'https://exhentai.org' + parse_gallery_identifier();
            targetWebsite = 'ExHentai';
        } // Determine if the current page is E-Hentai or ExHentai

//         if (document.location.href.indexOf('/g/') != - 1) {
//             var toAppend = '<p id="linker" class="g4"><img src="http://ehgt.org/g/mr.gif"><a href="' + link + '"> Switch to ' + targetWebsite + '</a></p>';
//             $('#gd5').append(toAppend);
//             $('#linker a').css('text-decoration', 'none');
//             $('#linker a').css('font-weight', 'bold');
//         } // Append the linker to switch between ExHentai gallery and E-Hentai gallery, if it's a gallery type of page

        $('#nb').append('<img src="http://ehgt.org/g/mr.gif" alt="">');
        if (targetWebsite == 'ExHentai') {
            if(document.location.href == 'https://upload.e-hentai.org/manage.php'){
                $('#nb').append('<a id="linker" href="https://exhentai.org/upload/manage.php"> To ExHentai</a>');
                $('#linker a, #linker').css('color', '#0000FF'); //Give blue color to linker
            } else {
                $('#nb').append('<a id="linker" href="https://exhentai.org'+parse_gallery_identifier()+'"> To ExHentai</a>');
                $('#linker a, #linker').css('color', '#0000FF'); //Give blue color to linker
            }
        } else {
            if(document.location.href == 'https://exhentai.org/upload/manage.php'){
                $('#nb').append('<a id="linker" href="https://upload.e-hentai.org/manage.php"> To E-Hentai</a>');
                $('#linker a, #linker').css('color', '#FFFF00'); //Give yellow color to linker
            } else {
                $('#nb').append('<a id="linker" href="https://e-hentai.org'+parse_gallery_identifier()+'"> To E-Hentai</a>');
                $('#linker a, #linker').css('color', '#FFFF00'); //Give yellow color to linker
            }
        } // Add option to switch between E-Hentai and ExHentai in the top bar of the page
    }
});

// Parse the gallery link
function parse_gallery_identifier() {
    var identifier_start;
    if (location.href.indexOf('e-hentai.org') != - 1) {
        identifier_start = location.href.indexOf('e-hentai.org')+12;
    }
    else if (location.href.indexOf('exhentai.org') != - 1) {
        identifier_start = location.href.indexOf('exhentai.org')+12;
    }
    var identifier_end = location.href.length;
    var identifier = location.href.substr(identifier_start, identifier_end);
    return identifier;
}