// ==UserScript== // @name Get_all_img_Library 2.0 // @namespace http://tampermonkey.net/ // @version 2025.09.27 // @description 重新重构 // @author You // @grant none // @grant GM_download // @grant GM_setValue // @grant GM_getValue // @grant GM_deleteValue // @require https://scriptcat.org/lib/3246/1.0.0/MyShowBox.js?sha384-+8wVwz6dbACCmp1POidoAkAlu9vUMQp+3UMXSIMEeujwBoROYKgRgRtv5f6D55Z8 // @require https://scriptcat.org/lib/3859/1.0.0/MyDownloaderBox.js?sha384-YE8UsSc6m3fmkF8WSCRzA5Omcx9976VTlqLdrOV4YXyxBSDNpTNoB7qebrQ5tLGO // ==/UserScript== /** * @description GAIL + showbox + downloadbox * @example let Geturl = i=>atag.eq(i)[0].href; let GetImg = data=>$(data).find('img').attr('big_src',src); let gail = new GAIL(); gail.SetFn({ GetUrlFn:GetUrl, GetImgFn:GetImg }) for(let i=0,i<100,i++){ gail.Go(i); } */ function GAIL(){ let G = this; this.getWay = "ajax"; this.downloadWay = "GM"; this.PutImgFn = null; this.private = { GetHtmlData:null, ShowBox:null, DownloadBox:null, }; this.SetFn = (args)=>{ this.GetUrlFn = args.GetUrlFn; this.GetImgFn = args.GetImgFn; if(args.PutImgFn) this.PutImgFn = args.PutImgFn; if(args.getWay) this.getWay = args.getWay; if(args.downloadWay) this.downloadWay = args.downloadWay; }; this.Go = async index=>{ try{ this.private.GetHtmlData = new GetHtmlDataFactory(this.getWay); let url = await this.GetUrlFn(index); let data = await this.private.GetHtmlData(url); let imgs = await this.GetImgFn(data); if(this.PutImgFn){ this.PutImgFn(imgs,index); }else{ this.private.ShowBox = new ShowBox(); this.private.DownloadBox = new DownloadBox(); this.private.ShowBox.Add(imgs); } }catch(error){ console.error(error); } }; $('.clickShowBox .downloadall').off('click').click(function(){ $(this).addClass('busy'); G.private.DownloadBox.AddImgs($('.clickShowBox .item img').clone()); $('li.item .name').first().click(); }); this.ShowMass = ms=> { if($('.mass_top').attr('class')){$('.mass_top').text(ms);return} $('body').append($('
').css({ 'font-size':'2vw', 'color':'rgba(0, 102, 0, 0.5)', 'position':'fixed', 'top':'10px', 'left':'10px', 'font-weight':'bold', 'z-index':99999999, }).click(function(){$(this).hide()})); $('.mass_top').text(ms); }; } function GetHtmlDataFactory(way) { const methods = { ajax: url => $.ajax({ url }), fetch: url => fetch(url).then(res => res.text()), }; return methods[way] || (() => { throw new Error(`Unsupported method: ${way}`); }); }