newtoblock & downloader

try to take over the world!

当前为 2020-11-01 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         newtoblock & 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...")
    }
};