Skip to content

Commit 2d2bd53

Browse files
committed
Update Picviewer CE+.user.js
1 parent fc3e474 commit 2d2bd53

1 file changed

Lines changed: 18 additions & 12 deletions

File tree

Picviewer CE+/Picviewer CE+.user.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
// @grant GM.notification
4747
// @grant unsafeWindow
4848
// @require https://update.greasyfork.org/scripts/6158/23710/GM_config%20CN.js
49-
// @require https://update.greasyfork.org/scripts/438080/1634900/pvcep_rules.js
49+
// @require https://update.greasyfork.org/scripts/438080/1636990/pvcep_rules.js
5050
// @require https://update.greasyfork.org/scripts/440698/1427239/pvcep_lang.js
5151
// @downloadURL https://greasyfork.org/scripts/24204-picviewer-ce/code/Picviewer%20CE+.user.js
5252
// @updateURL https://greasyfork.org/scripts/24204-picviewer-ce/code/Picviewer%20CE+.meta.js
@@ -11978,13 +11978,6 @@ ImgOps | https://imgops.com/#b#`;
1197811978
}else{
1197911979
_GM_setClipboard=(s)=>{};
1198011980
}
11981-
if(typeof GM_xmlhttpRequest!='undefined'){
11982-
_GM_xmlhttpRequest=GM_xmlhttpRequest;
11983-
}else if(typeof GM!='undefined' && typeof GM.xmlHttpRequest!='undefined'){
11984-
_GM_xmlhttpRequest=GM.xmlHttpRequest;
11985-
}else{
11986-
_GM_xmlhttpRequest=(f)=>{fetch(f.url).then(response=>response.text()).then(data=>{let res={response:data};f.onload(res)}).catch(f.onerror())};
11987-
}
1198811981
if(typeof GM_registerMenuCommand!='undefined'){
1198911982
_GM_registerMenuCommand=GM_registerMenuCommand;
1199011983
}else if(typeof GM!='undefined' && typeof GM.registerMenuCommand!='undefined'){
@@ -12006,7 +11999,7 @@ ImgOps | https://imgops.com/#b#`;
1200611999
_GM_xmlhttpRequest = GM.xmlHttpRequest;
1200712000
GM_fetch = true;
1200812001
} else {
12009-
_GM_xmlhttpRequest = (f) => {fetch(f.url, {method: f.method || 'GET', body: f.data || '', headers: f.headers}).then(response => response.text()).then(data => {f.onload({response: data})}).catch(f.onerror())};
12002+
_GM_xmlhttpRequest = (f) => {fetch(f.url, (f.method && f.method !== 'GET' ? {method: f.method || 'GET', body: f.data || '', headers: f.headers} : {method: 'GET', headers: f.headers})).then(response => response.text()).then(data => {f.onload({response: data})}).catch(f.onerror())};
1201012003
}
1201112004
if (typeof GM_addStyle != 'undefined') {
1201212005
_GM_addStyle = GM_addStyle;
@@ -24191,6 +24184,7 @@ ImgOps | https://imgops.com/#b#`;
2419124184
var handleError;
2419224185
var cacheNum = 0;
2419324186
var xhr;
24187+
var useFetch = false;
2419424188

2419524189
/**
2419624190
* @param q 图片的选择器或函数
@@ -24259,8 +24253,12 @@ ImgOps | https://imgops.com/#b#`;
2425924253
onload: function(req) {
2426024254
try {
2426124255
if(req.status > 399) throw 'Server error: ' + req.status;
24262-
cb(req.responseText, req.finalUrl || url);
24256+
else cb(req.responseText, req.finalUrl || url);
2426324257
} catch(ex) {
24258+
if (!useFetch && req.responseHeaders.indexOf("cloudflare") != -1) {
24259+
useFetch = true;
24260+
return downloadPage(url, post, headers, cb);
24261+
}
2426424262
handleError(ex);
2426524263
}
2426624264
},
@@ -24278,7 +24276,15 @@ ImgOps | https://imgops.com/#b#`;
2427824276
opts.headers = headers;
2427924277
}
2428024278

24281-
_GM_xmlhttpRequest(opts);
24279+
if (useFetch) {
24280+
let fetchOption = {method: opts.method || 'GET', headers: opts.headers};
24281+
if (opts.method && opts.method != 'GET') {
24282+
fetchOption.body = opts.data || '';
24283+
}
24284+
fetch(opts.url, fetchOption).then(response => response.text()).then(data => {opts.onload({responseText: data})}).catch(e => opts.onerror(e));
24285+
} else {
24286+
_GM_xmlhttpRequest(opts);
24287+
}
2428224288
}
2428324289

2428424290
function createDoc(text) {
@@ -24304,7 +24310,7 @@ ImgOps | https://imgops.com/#b#`;
2430424310

2430524311
function findFile(n, url) {
2430624312
pretreatment(n, true);
24307-
var path = n.src || n.href || (n.children && n.children[0] && n.children[0].src);
24313+
var path = (n.dataset && n.dataset.src) || n.src || n.href || (n.children && n.children[0] && n.children[0].src);
2430824314
if (/^video$/i.test(n.nodeName)) {
2430924315
path = "video:" + path;
2431024316
} else if (/^audio$/i.test(n.nodeName)) {

0 commit comments

Comments
 (0)