toggle

Toggles chapter's read state

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, Greasemonkey alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey alebo Userscripts.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie správcu používateľských skriptov.

(Už mám správcu používateľských skriptov, nechajte ma ho nainštalovať!)

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

(Už mám správcu používateľských štýlov, nechajte ma ho nainštalovať!)

// ==UserScript==
// @name         toggle
// @namespace    https://github.com/iugastefan
// @homepage     https://github.com/iugastefan/readtoggle/raw/master/toggle.user.js
// @version      0.4
// @description  Toggles chapter's read state
// @author       Iuga Stefan
// @match        https://mangadex.org/title/*
// @grant        none
// @license      BSD 3-Clause "New" or "Revised" License
// ==/UserScript==

(function() {
    'use strict';
    var but = document.createElement("button");
    but.className="btn btn-primary";
    var sp = document.createElement("span");
    sp.className = "fas fa-eye fa-fw";
    but.appendChild(sp);
    var t = document.createTextNode(" Toggle read status for all chapters");
    if(document.getElementsByClassName("chapter_mark_read_button").length === 0 && document.getElementsByClassName("chapter_mark_unread_button").length === 0) {
        t.textContent=" You need to follow to read";
        but.disabled=true;
    }
    but.appendChild(t);
    but.style.cursor = "pointer";
    but.onclick = function() {
        var x = document.getElementsByClassName("chapter_mark_read_button");
        if (x.length !== 0) {
            Array.from(x).forEach(function(item) {
                item.click();
            });
            but.disabled=true;
            t.textContent = " Refresh to toggle again";
        } else {
            x = document.getElementsByClassName("chapter_mark_unread_button");
            if (x.length !== 0) {
                Array.from(x).forEach(function(item) {
                    item.click();
                    but.disabled=true;
                    t.textContent = " Refresh to toggle again";
                });
            } else {
                console.log("Nothing to click");
            }
        }
    };
    document.getElementsByClassName("col-lg-9 col-xl-10")[document.getElementsByClassName("col-lg-9 col-xl-10").length-1].appendChild(but);
})();