dm5.com 自动加载章节图片

Lists all images in a chapter/volume

目前为 2019-02-21 提交的版本。查看 最新版本

// ==UserScript==
// @name               dm5.com 自动加载章节图片
// @description        Lists all images in a chapter/volume
// @name:zh-CN         DM5 漫画列表
// @description:zh-CN  列出章节内所有图片。原作者willy_sunny,原脚本https://greasyfork.org/zh-CN/scripts/25513-dm5-com-image-list。由于原脚本在网站更新后失效,因此在其基础上进行了修正。
// @version            1.1.0
// @include            /^http\:\/\/.*?\.dm5\.com\//
// @author             slinerd
// @license            GPL version 2 or any later version; http://www.gnu.org/licenses/gpl-2.0.txt
// @namespace https://greasyfork.org/users/165071
// ==/UserScript==
//
// ************************
// Own Variable Declaration
// ************************
// imgList: the output result
//

// 读取下一章url和标题
var x = document.getElementsByTagName("a");
var nextChapterUrl = "";
var nextChapterTitle = "无";
for (var i = 0; i < x.length; i++) {
    if (x[i].text == "下一话") {
        nextChapterUrl = x[i].href
        nextChapterTitle = x[i].title
    }
}

var imgList = "";
function lp(p, list, count, callback) {
    $.ajax({
        url: 'chapterfun.ashx',
        data: {
            cid: DM5_CID,
            page: p,
            key: $("#dm5_key").val(),
            language: 1,
            gtk: 6,
            _cid: DM5_CID,
            _mid: DM5_MID,
            _dt: DM5_VIEWSIGN_DT,
            _sign: DM5_VIEWSIGN
        },
        type: 'GET',
        success: function(data) {
            eval(data);
            if (p > count) {
                callback(list);
            } else {
                document.body.innerHTML = "Loading Page " + p + "/" + count;
                lp(p+1, list+'<div align="center"><img src="' + d[0] + '" ><br><br></div>', count, callback);
            }
        }
    })
}

// 加载图片
imgList = lp(1, "", DM5_IMAGE_COUNT,
             function(data) {
    document.body.innerHTML = data;

    // 增加下一章按钮
    var nextChapterButton;
    (nextChapterButton = document.createElement("button")).innerHTML = "下一话:" + nextChapterTitle;
    if (nextChapterUrl == "") {
        nextChapterButton.setAttribute("onclick", "alert('到头了')");
    } else {
        nextChapterButton.setAttribute("onclick", "location='"+nextChapterUrl+"'");
    }
    document.body.appendChild(nextChapterButton);

});