// ==UserScript== // @name For Imhentai // @namespace http://tampermonkey.net/ // @version 2.2 // @description 不翻墙下,更快加载 imhentai.xxx 的图片,并提供打包下载 // @author 水母 // @match https://imhentai.xxx/gallery/* // @match https://*.imhentai.xxx/* // @icon https://imhentai.xxx/images/logo.png // @require https://cdn.jsdelivr.net/npm/jszip@3.6.0/dist/jszip.min.js#sha512-uVSVjE7zYsGz4ag0HEzfugJ78oHCI1KhdkivjQro8ABL/PRiEO4ROwvrolYAcZnky0Fl/baWKYilQfWvESliRA== // @grant GM_setValue // @grant GM_getValue // @grant GM_download // @grant GM_openInTab // @license MIT // @downloadURL none // ==/UserScript== (function () { "use strict"; // 全局数据 let IS_INIT = false; let IS_RUN = false; let IS_DOWNLOADING = false; // 页码序列 [cover.jpg, 1.jpg, ..., 30.jpg] : cover不计入页数; eg.总页数定为 30; 数组 [0] 定为 cover /** * 当前页码 */ let CURRENT_PAGE = 0; /** * 最大浏览的页码,只增 */ let MAX_BROWSE_PAGE = 0; /** * 已加载的页码 */ let PAGE_LOADED = 0; /** * @desc 标识当前在哪个页面 */ let CURRENT_URL; /** * @desc 页面枚举 */ const CURRENT_URL_TYPE = { /** * @desc 标识在 https://imhentai.xxx/gallery/? 页面 */ gallery: "gallery", /** * @desc 标识在 https://imhentai.xxx/view/? 页面 */ view: "view", /** * @desc 标识在 https://?.imhentai.xxx/?/?/cover.jpg 页面 */ imgPage: "imgPage", /** * @desc 标识在 测试 gallery 页面 */ testGallery: "testGallery", /** * @desc 标识在 测试 view 页面 */ testView: "testView", /** * @desc 标识为无法识别页面 */ unknow: "unknow", }; /** * 用户定义的下载页码区间 */ let UserCustemRange = { min: 0, max: 0, page_loaded: 0, }; // enum const CanEleID = { /** * 主体 */ app: "can-app", runBtn: "can-run", previousBtn: "can-pre", nextBtn: "can-next", downloadBtn: "can-down", scaleUpBtn: "can-sUp", scaleResetBtn: "can-sReset", scaleDownBtn: "can-sDown", /** * 页码 */ pageLabel: "can-page", /** * 页码跳转 */ changePageInput: "can-input", /** * 图片显示 */ showImg: "can-img", /** * 图片显示外包