newtoblock

try to take over the world!

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         newtoblock
// @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()
let linklist = localStorage.getItem('clickedlist'); // get clicked element
// 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";
let clicked, clickedlist = JSON.parse(localStorage.getItem("clickedlist"));
if (clickedlist == null) {
    clickedlist = []
    console.log("welcome")
}
// check whether user is at viewpage
if (!$("[class ='view-content1']")[0]) {
    document.getElementById("main-banner-view").appendChild(sendBtn);
    let m = clickedlist.some(function (item) {
        return item[0] === document.URL
    });
    if (m == false) {
        var today = new Date();
        var date = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate();
        var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
        var dateTime = date + ' ' + time;
        clickedlist.push([document.URL, dateTime])
        window.localStorage.setItem("clickedlist", JSON.stringify(clickedlist))
        console.log(clickedlist)
    }
    else {
        console.log("you've visited")
    }
}

if ($("[class ='view-content1']")[0]){
    for (let i=0; i < clickedlist.length; i ++) {
        // console.log(typeof clickedlist[i])
        if ($('a[href*="' + clickedlist[i][0] + '"]')[0]){
            $('a[href*="' + clickedlist[i][0] + '"]')[0].style.color = "blue"
            $('a[href*="' + clickedlist[i][0] + '"]')[0].text += "("+clickedlist[i][1]+")";
        }
    }
    console.log(clickedlist)
    // let linkBtn = $("[class='item-subject']")
    // // $(document).on('click', 'a', false);
    // linkBtn.click(function (e) {
    //     console.log(e.target.getAttribute("href"))
    //     clicked = e.target.getAttribute("href")
    //     if (clickedlist.includes(clicked) == false){
    //         clickedlist.push(clicked)
    //     }
    //     // clicked.style.color = "blue";
    //     console.log(clickedlist)
    //     window.localStorage.setItem("clickedlist", JSON.stringify(clickedlist))
    // });
}
var regex = /\d+/g, mnum = (parent.window.location.pathname != "/") ? parent.window.location.pathname.match(regex)[0] : 0;
console.log(mnum)
// 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']"), loadimg = $('img[src$="/img/loading-image.gif"]'), 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, 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...")
    }
};