newtoki, manatoki adblockor & downloader

try to take over the world!

目前為 2020-11-01 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         newtoki, manatoki adblockor & downloader
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @include        http*://manatoki*
// @grant GM_download
// ==/UserScript==
// adblock
$('.hd_pops').remove()
$('.board-tail-banner').remove()
$('.basic-banner.row.row-10').remove()
// append download button
var sendBtn = document.createElement("button");
sendBtn.className = "btn btn-warning";
sendBtn.style.zIndex = "3";
sendBtn.style.position = "fixed";
sendBtn.style.bottom = "0";
sendBtn.style.right = "0";
sendBtn.innerText = "download";
// check whether user is at viewpage
if (document.URL.includes("board") == false) {
    document.getElementById("main-banner-view").appendChild(sendBtn);
}
var flen;
var regex = /\d+/g;
var mnum = document.URL.match(regex)[1];
// get page title and manga number
sendBtn.onclick = function() {
    // let canvas = $("img[src*='/data/file/comic'][src*="+mnum+"]").not("img[src*='thumb']")
    var title = document.getElementsByClassName('page-desc')[0].innerHTML
    let canvas = $("img[src*='/data/']").not("img[src*='thumb']")
    let loadimg = $('img[src$="/img/loading-image.gif"]')
    let countedword = {}
    // check if loading is completed
    if (loadimg.length <= 1) {
        // get every image which contains '/data/' and classify with parentNode inside the object
        for (let i = 0; i < canvas.length; i++) {
            var word = canvas[i].parentNode
            if (countedword[word.className] == undefined) {
                countedword[word.className] = 1;
            } else {
                countedword[word.className] += 1;
            }
        }
        //get the manga image from the object
        let a = 0;
        let viewdiv = Object.keys(countedword)[1]
        console.log(viewdiv);
        console.log(countedword)
        // download every manga images every 0.3 sec
        for (let i = 0; i < canvas.length; i++) {
            (function(x) {
                setTimeout(function() {
                    let word = canvas[i].parentNode
                    if (word.className == viewdiv) {
                        a += 1
                        var blob = canvas[i].currentSrc
                        let arg = {
                            url: blob,
                            name: title + a
                        };
                        GM_download(arg)
                    }
                }, 300 * x);
            })(i);
        }
    } else {
        alert("wait for loading...")
    }
};