// ==UserScript==
// @name 微博图片批量下载-支持无水印
// @author Shawlj
// @namespace http://tampermonkey.net/
// @description 本程序支持新版微博图片批量下载功能
// @version v1.4
// @match https://weibo.com/*
// @match https://d.weibo.com/*
// @match https://s.weibo.com/*
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/jszip/3.2.0/jszip.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/dayjs/1.11.10/dayjs.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.8/FileSaver.min.js
// @resource xinfo https://cdn.jsdelivr.net/gh/Mr-Po/weibo-resource-download/out/media/info.png
// @resource xsuccess https://cdn.jsdelivr.net/gh/Mr-Po/weibo-resource-download/out/media/success.png
// @resource xerror https://cdn.jsdelivr.net/gh/Mr-Po/weibo-resource-download/out/media/error.png
// @connect sinaimg.cn
// @connect weibo.com
// @compatible chrome
// @compatible firefox
// @license MIT
// @grant GM_xmlhttpRequest
// @grant GM_getResourceURL
// @grant GM_registerMenuCommand
// @grant GM_unregisterMenuCommand
// @grant GM_notification
// @grant GM_setClipboard
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_addStyle
// @grant GM_addElement
// @grant GM_deleteValue
// @grant GM_openInTab
// @grant GM_download
// @grant window.onurlchange
// ==/UserScript==
(function() {
var _$_f4ac=["use strict","xerror","xsuccess","xinfo","https://{0}weibo.com/","https://wx{0}.sinaimg.cn","https://greasyfork.org/zh-CN/scripts/478066","#eb7340","#0000FF","#02A642","#FF0000","woo-font woo-font--imgSave","vue-recycle-scroller__item-wrapper","[class^=\"Feed_body\"]","[class*=\"picture-tool-bar_toolbarSpin\"]","picture-viewer_previewList","picture-viewer_listContentAnimate","picture-viewer_imgWrap","picture-viewer_showPictureViewer","a[usercard]>span,a[class^=head-info_time]","[class^=\"picture-viewer_imgWrap\"] img","pl_feedlist_index","ul.tab","media-pic-zoom","content","choose-pic","card-comment","a.name,.from a","[suda-data^=key]","[node-type=\"imgBox\"]>img","ready","urlchange","addEventListener","xvalid","type","childList","addedNodes","mpz","s","|","pvs","m","","className","target","xwb_btn","siw",", ","fby",", #","pfi","querySelectorAll","length",")","observe","wurl","s.","href","tab","querySelector","cpc","cct","closest","toArray","iuk","filter","iut","find","con","slice","YYYYMMDDHHmm","innerText","replace","format","padEnd","@","map","attr","article","title","textContent","pvl","\"]","pvi","<a style=\'color:{0}\'>{1}</a>","outerHTML","empty","context","lastChild","\"] img","pop","/","split","src","firstChild","children","append","remove","$xwbn-wsy","\u65e0\u6c34\u5370","\u9ed8\u8ba4","cr4","c","click","cr2","\u4e0b\u8f7d\u56fe\u7247","cr1","size","cr3","color","style","childNodes","nodeType","TEXT_NODE","nodeValue","img",",","indexOf","\u7f51\u9875\u89e3\u6790\u9519\u8bef\uff0c\u9875\u9762\u5143\u7d20\u5df2\u53d8\u66f4\uff0c\u8bf7\u524d\u5f80\u5b98\u65b9\u5347\u7ea7\u6700\u65b0\u7248","purl","?referer=","ok","status","blob","-","padStart","push","error","\u5f53\u524d\u670d\u52a1\u5668\u8bbf\u95ee\u5931\u8d25\uff0c\u8bf7\u518d\u6b21\u5c1d\u8bd5\u4e0b\u8f7d","xurl","catch","\u56fe\u7247\u4e0b\u8f7d\u5b8c\u6210 (\u63d0\u793a: \u82e5\u3010\u65e0\u6c34\u5370\u3011\u4e0b\u8f7d\u6570\u91cf\u7f3a\u5c11, \u8bf7\u5355\u72ec\u4e0b\u8f7d\u5269\u4f59\u56fe\u7247)","then","all","\x0A","join","oslarge","large","menu_list","YYYYMMDDHHmmssSSS","match","\u590d\u5236\u6210\u529f\uff01","\u590d\u5236\u5931\u8d25\uff1a","writeText","clipboard","object","forEach","values","undefined","each","set","test","log","random","floor","\\{","\\}","gm","menu_ids","$xwbp-xdn","\u811a\u672c\u542f\u7528","(Alt+0)","$xwbn-xms","\u6d88\u606f\u901a\u77e5","(Alt+1)","\u5f00\u542f\u65e0\u6c34\u5370\u4e0b\u8f7d (\u753b\u8d28\u538b\u7f29)","(Alt+2)","$xwbf-xn1","\u6587\u4ef6\u540d\uff1a\u6635\u79f0 (\u539f)","(Alt+3)","$xwbf-xt1","\u6587\u4ef6\u540d\uff1a\u65f6\u95f4 (\u539f)","(Alt+4)","$xwbf-xn2","\u6587\u4ef6\u540d\uff1a\u6635\u79f0 (\u8f6c)","(Alt+5)","$xwbf-xt2","\u6587\u4ef6\u540d\uff1a\u65f6\u95f4 (\u8f6c)","(Alt+6)","$xwbf-sfm","\u6587\u4ef6\u540d\uff1a\u65f6\u5206\u79d2","(Alt+7)","$xwbf-stm","\u6587\u4ef6\u540d\uff1a\u65f6\u95f4\u6233","(Alt+8)","splice"," ","xswitch","\ud83d\udcac \u53cd\u9988 & \u5efa\u8bae","main","xregister","event","keyCode","which","altKey","keydown","xkeyboard"];(function(){_$_f4ac[0];const E={0:_$_f4ac[1],1:_$_f4ac[2],2:_$_f4ac[3]};const F={attributes:false,childList:true,subtree:true};const G={wurl:_$_f4ac[4],purl:_$_f4ac[5],main:_$_f4ac[6]};const H={c:{cr1:_$_f4ac[7],cr2:_$_f4ac[8],cr3:_$_f4ac[9],cr4:_$_f4ac[10],ico:_$_f4ac[11]},m:{siw:_$_f4ac[12],fby:_$_f4ac[13],tab:_$_f4ac[14],pvp:_$_f4ac[15],pvl:_$_f4ac[16],pvi:_$_f4ac[17],pvs:_$_f4ac[18],iut:_$_f4ac[19],img:_$_f4ac[20]},s:{pfi:_$_f4ac[21],tab:_$_f4ac[22],mpz:_$_f4ac[23],con:_$_f4ac[24],cpc:_$_f4ac[25],cct:_$_f4ac[26],iut:_$_f4ac[27],iuk:_$_f4ac[28],img:_$_f4ac[29]}};$(document)[_$_f4ac[30]]($xlistener);window[_$_f4ac[32]](_$_f4ac[31],()=>{setTimeout(()=>{return $xlistener()},2000)});function $xlistener(){if(I[_$_f4ac[33]](48)){const bh= new MutationObserver((bj,F)=>{for(var bi of bj){if(bi[_$_f4ac[34]]=== _$_f4ac[35]){const bk=bi[_$_f4ac[36]][0];if(bk&& $xtest((""+H[_$_f4ac[38]][_$_f4ac[37]]+_$_f4ac[39]+H[_$_f4ac[41]][_$_f4ac[40]]+_$_f4ac[42]),bk[_$_f4ac[43]])){$xcreate(bi[_$_f4ac[44]],_$_f4ac[45])}}}});const bg=document[_$_f4ac[51]](("."+H[_$_f4ac[41]][_$_f4ac[46]]+_$_f4ac[47]+H[_$_f4ac[41]][_$_f4ac[48]]+_$_f4ac[49]+H[_$_f4ac[38]][_$_f4ac[50]]+_$_f4ac[42]));if(!$xnull(bg)){$xlog(("\u5fae\u535a\u56fe\u7247\u6279\u91cf\u4e0b\u8f7d\u7a0b\u5e8f\u51c6\u5907\u5c31\u7eea("+bg[_$_f4ac[52]]+_$_f4ac[53]));for(let bf of bg){bh[_$_f4ac[54]](bf,F)}}}}const $xcreate=(ba,bs)=>{let bt,bv,be=[];const br=$xtest($xformat(G[_$_f4ac[55]],_$_f4ac[56]),location[_$_f4ac[57]]);let bw=ba[_$_f4ac[59]](br?H[_$_f4ac[38]][_$_f4ac[58]]:H[_$_f4ac[41]][_$_f4ac[58]]);if(br){bv= H[_$_f4ac[38]][_$_f4ac[60]];const bq=$(ba)[_$_f4ac[62]](("."+H[_$_f4ac[38]][_$_f4ac[61]]+_$_f4ac[42]))[_$_f4ac[52]];be= $(ba)[_$_f4ac[62]](("."+H[_$_f4ac[38]][_$_f4ac[68]]+_$_f4ac[42]))[_$_f4ac[67]](H[_$_f4ac[38]][_$_f4ac[66]])[_$_f4ac[65]](H[_$_f4ac[38]][_$_f4ac[64]])[_$_f4ac[63]]();be= be[_$_f4ac[69]](0,bq?4:2);if(be[_$_f4ac[52]]){const bp=_$_f4ac[70];be= be[_$_f4ac[76]]((bA,M)=>{let by=bA[_$_f4ac[71]];if(M% 2!= 0){by= by[_$_f4ac[72]](/[\u4e00-\u9fa5:\s]/g,_$_f4ac[42]);const bx=by[_$_f4ac[52]];let bz=bx< 3?bp:bx< 5?bp[_$_f4ac[69]](0,8):bx< 9?bp[_$_f4ac[69]](0,4):null;if(bz){by= dayjs()[_$_f4ac[73]](bz)+ by};return by[_$_f4ac[74]](14,0)}else {return by[_$_f4ac[72]](_$_f4ac[75],_$_f4ac[42])}})}}else {if(bw&& $xnull($(bw)[_$_f4ac[77]](bs))){be= $(ba)[_$_f4ac[62]](_$_f4ac[78])[_$_f4ac[67]](H[_$_f4ac[41]][_$_f4ac[66]])[_$_f4ac[63]]();if(be[_$_f4ac[52]]){be= be[_$_f4ac[76]]((bA)=>{return (bA[_$_f4ac[79]]|| bA[_$_f4ac[80]])[_$_f4ac[72]](/[@\-\:\s]/g,_$_f4ac[42])})};const bu=$(ba)[_$_f4ac[67]](("[class*=\""+H[_$_f4ac[41]][_$_f4ac[81]]+_$_f4ac[82]))[_$_f4ac[52]];bv= bu> 0?H[_$_f4ac[41]][_$_f4ac[81]]:H[_$_f4ac[41]][_$_f4ac[83]]}};if(!$xnull(be)){$xbutton(ba,bw,be,bv,br,bs)}};const $xbutton=(ba,bw,be,bB,br,bs)=>{let bD=_$_f4ac[84];let bC=$($(bw[_$_f4ac[88]])[_$_f4ac[87]][_$_f4ac[85]])[_$_f4ac[86]]()[0][_$_f4ac[85]];const bF=$(ba)[_$_f4ac[67]](("div[class*=\""+bB+_$_f4ac[89]))[_$_f4ac[63]]();const N= new Set(bF[_$_f4ac[76]]((bA,M)=>{return bA[_$_f4ac[93]][_$_f4ac[92]](_$_f4ac[91])[_$_f4ac[90]]()}));let bE=_$_f4ac[42];let bo=bw[_$_f4ac[94]];if(!br){bE= $(bw[_$_f4ac[95]][1])[_$_f4ac[87]][_$_f4ac[85]];$(bw)[_$_f4ac[96]](bE)[_$_f4ac[77]](bs,bs)}else {bo= bo[_$_f4ac[94]];$(bw[_$_f4ac[95]][2])[_$_f4ac[97]]()};let bG=$xget(_$_f4ac[98])?_$_f4ac[99]:_$_f4ac[100];$xtextNode(bo,bG,H[_$_f4ac[102]][_$_f4ac[101]]);$(bw)[_$_f4ac[96]]($(bC)[_$_f4ac[96]]($xformat(bD,H[_$_f4ac[102]][_$_f4ac[104]],_$_f4ac[105]))[_$_f4ac[103]](()=>{return $xdownpic(ba,be,N,true)}))[_$_f4ac[96]](bE);$(bw)[_$_f4ac[96]]($(bC)[_$_f4ac[96]]($xformat(bD,H[_$_f4ac[102]][_$_f4ac[106]],("\u4e0b\u8f7d\u5168\u90e8("+N[_$_f4ac[107]]+_$_f4ac[53])))[_$_f4ac[103]](()=>{return $xdownpic(ba,be,N)}))[_$_f4ac[96]](bE);$(bw)[_$_f4ac[96]]($(bC)[_$_f4ac[96]]($xformat(bD,H[_$_f4ac[102]][_$_f4ac[108]],("\u590d\u5236\u94fe\u63a5("+N[_$_f4ac[107]]+_$_f4ac[53])))[_$_f4ac[103]](()=>{return $xcopyurl(N)}))[_$_f4ac[96]](bE)};function $xtextNode(bo,bm,bn){if(bo){if(bn){bo[_$_f4ac[110]][_$_f4ac[109]]= bn};const bl=bo[_$_f4ac[111]];for(var M=0;M< bl[_$_f4ac[52]];M++){if(bl[M][_$_f4ac[112]]=== Node[_$_f4ac[113]]){bl[M][_$_f4ac[114]]= bm;break}}}}async function $xdownpic(ba,be,N,Y){let L,bc=[...N];let bb=true;if(Y){let Z=$(ba)[_$_f4ac[67]]((""+H[_$_f4ac[41]][_$_f4ac[115]]+_$_f4ac[116]+H[_$_f4ac[38]][_$_f4ac[115]]+_$_f4ac[42]));if(Z){const bd=$xmatch(/\/([^\/?#]+)[^\/]*$/,Z[0][_$_f4ac[93]]);L= bc[_$_f4ac[117]](bd);bc= [bd]}else {bb= $xalert(_$_f4ac[118])}};if(bb){ await $xdowndata(bc,$xfname(be),L)}}async function $xdowndata(N,K,L){let P=$xlossy();const Q=encodeURIComponent($xformat(G[_$_f4ac[55]],_$_f4ac[42]));const O=[];for(let M=0;M< N[_$_f4ac[52]];M++){O[_$_f4ac[126]]( new Promise(async (T,S)=>{const V=(""+$xformat(G[_$_f4ac[119]],$xrandom(4))+_$_f4ac[91]+P+_$_f4ac[91]+N[M]+_$_f4ac[120]+Q+_$_f4ac[42]);const U= await fetch(V);if(!U[_$_f4ac[121]]){S({error:U[_$_f4ac[122]],xurl:V})};const R= await U[_$_f4ac[123]]();let W=$xnull(L)?M:L;saveAs(R,(""+K+_$_f4ac[124]+String(W+ 1)[_$_f4ac[125]](2,0)+_$_f4ac[42]));T()})); await new Promise((T)=>{return setTimeout(T,200)})};Promise[_$_f4ac[133]](O)[_$_f4ac[132]](()=>{$xtip(_$_f4ac[131],1)})[_$_f4ac[130]]((X)=>{$xtip(("\u8bf7\u6c42\u5f02\u5e38: "+X[_$_f4ac[127]]+_$_f4ac[42]),0);$xlog(_$_f4ac[128],X[_$_f4ac[129]])})}const $xcopyurl=(N)=>{$xcopy([...N][_$_f4ac[76]]((bH)=>{return (""+$xformat(G[_$_f4ac[119]],$xrandom(4))+_$_f4ac[91]+$xlossy()+_$_f4ac[91]+bH+_$_f4ac[42])})[_$_f4ac[135]](_$_f4ac[134]))};const $xlossy=()=>{return I[_$_f4ac[33]](50)?_$_f4ac[136]:_$_f4ac[137]};const $xfname=(be)=>{const bI= new Array();const bb=I[_$_f4ac[33]](55);$xlog(I);$xfor(I[_$_f4ac[138]],(bJ,M)=>{$xlog(bJ);if($xget(bJ[0])){let bK=be[M- 3];$xlog(bK);$xlog(("\u65b0\u5faa\u73af\u8fed\u4ee3\u503c\uff1a "+bK+_$_f4ac[42]));if(bK){if(M% 3!== 0){bI[_$_f4ac[126]](bb?bK:bK[_$_f4ac[69]](0,8))}else {bI[_$_f4ac[126]](bK)}}}},[3,6]);if(I[_$_f4ac[33]](56)){bI[_$_f4ac[126]](dayjs()[_$_f4ac[73]](_$_f4ac[139]))};return bI[_$_f4ac[135]](_$_f4ac[124])};const $xbutton1=(bM,bL)=>{return $($xformat(G[_$_f4ac[57]],bM))[_$_f4ac[103]](bL)};const $xmatch=(bO,bm)=>{var bN=bm[_$_f4ac[140]](bO);return bN[_$_f4ac[52]]> 1?bN[1]:null};const $xcopy=(bP)=>{navigator[_$_f4ac[144]][_$_f4ac[143]](bP)[_$_f4ac[132]](function(){$xlog(_$_f4ac[141])},function(bQ){$xlog(_$_f4ac[142],bQ)})};const $xfor=(bR,bS,bT= [0,array[_$_f4ac[52]]])=>{if(bR){let bU=bT[0];let X=bT[1];if( typeof bR=== _$_f4ac[145]){Object[_$_f4ac[147]](bR)[_$_f4ac[146]]((bJ,M)=>{if(M>= bU&& M<= X){bS(bJ,M,bR)}})}else {for(let M=bU;M< X;M++){bS(bR[M],M,bR)}}}};const $xnull=(bA)=>{if(bA=== undefined|| bA== _$_f4ac[148]|| typeof bA== _$_f4ac[148]){return true}else {if(bA== null|| bA[_$_f4ac[52]]< 1|| bA=== _$_f4ac[42]){return true}else {if( typeof bA== _$_f4ac[145]){return bA[_$_f4ac[52]]== 0}}};return false};const $xsetv=(bV,bW)=>{if($xnull(bW)){$[_$_f4ac[149]](bV,(bA,bW)=>{return $xset(bA,bW)});return bV}else {return $xset(bV,bW)}};const $xdelv=(...bV)=>{return bV[_$_f4ac[146]]((bA)=>{return $xdel(bA)})};const $xgetv=(bV,bW,bU)=>{if($xnull($xget(bV))){$xset(bV,bW)};return $xget(bV)};const $xsetm=(bJ,bA,M)=>{if(M== 1){bJ= new Map()};$[_$_f4ac[149]](bA,(bV,bW)=>{bJ[_$_f4ac[150]](bV,bW)})};const $xset=(bV,bW)=>{GM_setValue(bV,bW);return bW};const $xget=(bV)=>{return GM_getValue(bV)};const $xdel=(bV)=>{return GM_deleteValue(bV)};const $xcss=(bX)=>{return GM_addStyle(bX)};const $xtest=(bY,bU)=>{return new RegExp(bY)[_$_f4ac[151]](bU)};const $xbool=(Y)=>{return /^true$/i[_$_f4ac[151]](Y)};const $xlog=(...bZ)=>{return console[_$_f4ac[152]](...bZ)};const $xerr=(...bZ)=>{return console[_$_f4ac[127]](...bZ)};const $xalert=(...bZ)=>{console[_$_f4ac[152]](...bZ);alert(bZ[0])};const $xtip=(bA,bX,ca)=>{if(I[_$_f4ac[33]](49)){GM_notification({title:ca,text:bA,image:GM_getResourceURL(E[bX]),timeout:3000})}};const $xrandom=(cb)=>{return Math[_$_f4ac[154]](Math[_$_f4ac[153]]()* cb)+ 1};const $xformat=function(){if(arguments[_$_f4ac[52]]== 0){return null};var bm=arguments[0];for(var M=1;M< arguments[_$_f4ac[52]];M++){var cc= new RegExp(_$_f4ac[155]+ (M- 1)+ _$_f4ac[156],_$_f4ac[157]);bm= bm[_$_f4ac[72]](cc,arguments[M])};return bm};class J{ constructor(){this[_$_f4ac[158]]= new Array(9);this[_$_f4ac[138]]= {48:[_$_f4ac[159],_$_f4ac[160],true,_$_f4ac[161]],49:[_$_f4ac[162],_$_f4ac[163],true,_$_f4ac[164]],50:[_$_f4ac[98],_$_f4ac[165],true,_$_f4ac[166]],51:[_$_f4ac[167],_$_f4ac[168],true,_$_f4ac[169]],52:[_$_f4ac[170],_$_f4ac[171],true,_$_f4ac[172]],53:[_$_f4ac[173],_$_f4ac[174],false,_$_f4ac[175]],54:[_$_f4ac[176],_$_f4ac[177],false,_$_f4ac[178]],55:[_$_f4ac[179],_$_f4ac[180],true,_$_f4ac[181]],56:[_$_f4ac[182],_$_f4ac[183],true,_$_f4ac[184]]}} xregister(){this[_$_f4ac[158]][_$_f4ac[146]]((bJ)=>{return GM_unregisterMenuCommand(bJ)});Object[_$_f4ac[147]](this[_$_f4ac[138]])[_$_f4ac[146]]((ce,cd)=>{ce[_$_f4ac[185]](2,1,$xgetv(ce[0],ce[2]));this[_$_f4ac[158]][cd]= GM_registerMenuCommand((""+(ce[2]?"\u2705":"\u274c")+_$_f4ac[186]+ce[1]+_$_f4ac[186]+ce[3]+_$_f4ac[42]),()=>{return this[_$_f4ac[187]](ce)});cd> 7&& this[_$_f4ac[158]][_$_f4ac[126]](GM_registerMenuCommand(_$_f4ac[188],()=>{return GM_openInTab(G[_$_f4ac[189]])}))});return this} xswitch(bJ){if(bJ){this[_$_f4ac[190]]($xset(bJ[0],!bJ[2]))}} xkeyboard(){$(document)[_$_f4ac[195]]((cf)=>{let X=cf|| window[_$_f4ac[191]];let bV=X[_$_f4ac[192]]|| X[_$_f4ac[193]];if(X[_$_f4ac[194]]&& bV){this[_$_f4ac[187]](this[_$_f4ac[138]][bV])};return true});return this} xvalid(bV){return $xget(this[_$_f4ac[138]][bV][0])}};const I= new J()[_$_f4ac[190]]()[_$_f4ac[196]]()})()
})();