Proxer-Longstrip-Reader

Dieses Script fügt auf Proxer die Möglichkeit hinzu, Mangas im Longstrip-Format zu lesen

Stan na 10-06-2015. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Proxer-Longstrip-Reader
// @namespace    
// @version      0.6
// @description  Dieses Script fügt auf Proxer die Möglichkeit hinzu, Mangas im Longstrip-Format zu lesen
// @author       Dominik Bissinger alias Nihongasuki
// @include      http://proxer.me/*
// @include      https://proxer.me/*
// @include      http://www.proxer.me/*
// @include      https://www.proxer.me/*        
// @run-at       document-start
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        unsafeWindow
// ==/UserScript==

//Startet die Funktion "addButton" beim Laden der Seite
document.addEventListener('DOMContentLoaded', function(event) {
    addButton();
});

//Fügt den Button "Longstrip-Reader" zu "Anker" hinzu und startet die Longstrip-Funktion beim Seitenaufruf
var location = "";
var addButton = function() {
    var test = setInterval(function () {
        if (document.getElementById('anker') !== null) {
            var ul = document.getElementById("anker");
            var li = document.createElement("li");
            li.setAttribute("id","longstrip");
            ul.appendChild(li);
            document.getElementById('longstrip').innerHTML = '<a href="javascript:;">Longstrip-Reader</a>';
            document.getElementById('longstrip').addEventListener("click",function () {
            onOff();
            });
            location = window.location.href;
            var t = setInterval(repeat,250);
            longstrip();
            clearInterval(test);
        };
    },100);
};

//Toggle Longstrip-Reader
var onOff = function () {
    var x = GM_getValue("onOff",0);
    if (x === 0) {
        GM_setValue("onOff",1);
    }else{
        GM_setValue("onOff",0);
    };
};

//Setzt das Aussehen des Buttons und startet die Longstrip-Funktion, wenn sich die URL ändert
var repeat = function () {
    var x = GM_getValue("onOff",0);
    if (x === 0) {
        document.getElementById('longstrip').innerHTML = '<a href="javascript:;">Longstrip-Reader <img src="https://proxer.me/images/misc/kreuz.png" width="15" height="15"></a>';
    }else{
        document.getElementById('longstrip').innerHTML = '<a href="javascript:;">Longstrip-Reader <img src="https://proxer.me/images/misc/haken.png" width="15" height="15"></a>';
    };
    if (location !== window.location.href) {
        longstrip();
    };
};

//Longstrip-Reader
var longstrip = function () {
    location = window.location.href;
    var x = GM_getValue("onOff",0);
    if (x === 0) {
        return;
    };
    if (window.location.href.indexOf('read') > -1) {
        var lang = "";
        if (window.location.href.indexOf('en') > -1) {
            lang = "en";
        }else{
            lang = "de";
        };
        var href = window.location.href;
        var info = href.match(/(\d[\d\.]*)/g);
        var i = 1;
        var x = 0;
        
        //Ändere die Navigationseinstellungen
        window.addEventListener("keydown", changeChapter, false);
        
        //setze die Bilder
        var number = parseInt(info[1],10);
        var nextChap = number + 1;
        document.getElementById('reader').innerHTML = "<a href='/chapter/" +info[0]+ "/" +nextChap+ "/" +lang+ "' id='master'></a>";
        var master = document.getElementById('master');
        document.getElementById('reader').style.maxWidth = "none";
        document.getElementById('reader').style.textAlign = "center";
        var pages = document.getElementById('pages').innerHTML;
        var num = pages.match(/(\d[\d\.]*)/g);
        var pagesNumber = num[1];
        while (i <= pagesNumber) {
            var element = document.createElement("img");
            var url = "//upload.proxer.me/manga/"+info[0]+"_"+lang+"/"+info[1]+"/"+unsafeWindow.pages[x][0];
            element.setAttribute("class","chapterImage");
            element.setAttribute("src",url);
            element.setAttribute("width",unsafeWindow.pages[x][2]);
            element.setAttribute("height",unsafeWindow.pages[x][1]);
            element.setAttribute("style","opacity: 1; max-width: 100%; text-align: center;");
            master.appendChild(element);
            i++;
            x++;
        };
    };
};

//Weiterleitung zum nächsten Kapitel/zur Kapitelseite des momentanen Kapitels
var changeChapter = function (event) {
    var lang = "";
    if (window.location.href.indexOf('en') > -1) {
        lang = "en";
    }else{
        lang = "de";
    };
    var href = window.location.href;
    var info = href.match(/(\d[\d\.]*)/g);
    var number = parseInt(info[1],10);
    var nextChap = number + 1;
    var formerChap = number;
    if (event.keyCode === 68 || event.keyCode === 39) {
        window.location = "/chapter/" +info[0]+ "/" +nextChap+ "/" +lang;
    }else if (event.keyCode === 65 || event.keyCode === 37) {
        window.location = "/chapter/" +info[0]+ "/" +formerChap+ "/" +lang;
    };
};