Skip to content

Commit c0375d0

Browse files
committed
Update Picviewer CE+.user.js
1 parent 2223860 commit c0375d0

File tree

1 file changed

+39
-44
lines changed

1 file changed

+39
-44
lines changed

Picviewer CE+/Picviewer CE+.user.js

Lines changed: 39 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// @description:ja 画像を強力に閲覧できるツール。ポップアップ表示、拡大・縮小、回転、一括保存などの機能を自動で実行できます
1313
// @description:pt-BR Poderosa ferramenta de visualização de imagens on-line, que pode pop-up/dimensionar/girar/salvar em lote imagens automaticamente
1414
// @description:ru Мощный онлайн-инструмент для просмотра изображений, который может автоматически отображать/масштабировать/вращать/пакетно сохранять изображения
15-
// @version 2025.7.5.1
15+
// @version 2025.7.22.1
1616
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAAV1BMVEUAAAD////29vbKysoqKioiIiKysrKhoaGTk5N9fX3z8/Pv7+/r6+vk5OTb29vOzs6Ojo5UVFQzMzMZGRkREREMDAy4uLisrKylpaV4eHhkZGRPT08/Pz/IfxjQAAAAgklEQVQoz53RRw7DIBBAUb5pxr2m3/+ckfDImwyJlL9DDzQgDIUMRu1vWOxTBdeM+onApENF0qHjpkOk2VTwLVEF40Kbfj1wK8AVu2pQA1aBBYDHJ1wy9Cf4cXD5chzNAvsAnc8TjoLAhIzsBao9w1rlVTIvkOYMd9nm6xPi168t9AYkbANdajpjcwAAAABJRU5ErkJggg==
1717
// @namespace https://github.com/hoothin/UserScripts
1818
// @homepage https://github.com/hoothin/UserScripts/tree/master/Picviewer%20CE%2B
@@ -12226,6 +12226,22 @@ ImgOps | https://imgops.com/#b#`;
1222612226
};
1222712227
img.src = dataurl;
1222812228
}
12229+
function urlToBlobWithFetch(urlString, cb){
12230+
fetch(urlString).then(response => response.blob()).then(blob => cb(blob)).catch(error => {
12231+
cb(null);
12232+
});
12233+
}
12234+
function getCookie(cname) {
12235+
let name = cname + "=";
12236+
var ca = document.cookie.split(';');
12237+
for(let i = 0; i < ca.length; i++) {
12238+
let c = ca[i];
12239+
while (c.charAt(0)==' ') c = c.substring(1);
12240+
if (c.indexOf(name) == 0)
12241+
return c.substring(name.length,c.length);
12242+
}
12243+
return "";
12244+
}
1222912245
var cookie;
1223012246
function urlToBlob(url, cb, forcePng, tryTimes = 0) {
1223112247
tryTimes++;
@@ -12255,8 +12271,12 @@ ImgOps | https://imgops.com/#b#`;
1225512271
a.readAsDataURL(blob);
1225612272
a.onload = function (e) {
1225712273
dataURLToCanvas(e.target.result, canvas => {
12258-
canvas.toBlob(blob => {
12259-
cb(blob, conversion || "png");
12274+
canvas.toBlob(nblob => {
12275+
if (!nblob) {
12276+
cb(blob, ext || "png");
12277+
} else {
12278+
cb(nblob, conversion || "png");
12279+
}
1226012280
}, "image/" + (conversion || "png"));
1226112281
});
1226212282
};
@@ -14533,7 +14553,7 @@ ImgOps | https://imgops.com/#b#`;
1453314553
let picName = (saveIndex < 10 ? "00" + saveIndex : (saveIndex < 100 ? "0" + saveIndex : saveIndex)) + (title ? "-" + title : ""), hostArr = location.host.split(".");
1453414554
let host = hostArr[hostArr.length-2];
1453514555
saveParams.push([node.dataset.src, picName]);
14536-
if (node.dataset.srcs) {
14556+
if (node.dataset.srcs && node.dataset.srcs != node.dataset.src) {
1453714557
node.dataset.srcs.split(",").forEach(src => {
1453814558
saveParams.push([src, picName]);
1453914559
});
@@ -15622,26 +15642,24 @@ ImgOps | https://imgops.com/#b#`;
1562215642
});
1562315643
}
1562415644
if(canvas && (/^data:/.test(imgSrc) || imgSrc.split("/")[2] == document.domain)){
15625-
self.dataURLToCanvas(imgSrc, canvas=>{
15626-
self.showTips("Downloading "+(downloaded+1)+"/"+len, 1000000);
15627-
if(!canvas){
15645+
urlToBlobWithFetch(imgSrc, blob=>{
15646+
if(!blob){
1562815647
crosHandler(imgSrc);
1562915648
return;
1563015649
}
15631-
canvas.toBlob(blob=>{
15632-
zip.file(imgName.replace(/^data:.*/, "img").replace(/\//g,""), blob);
15633-
downloaded++;
15634-
over && over();
15635-
if(downloaded == len){
15636-
self.showTips(`Begin compress to ${packName}...`, 100000);
15637-
zip.generateAsync({type:"blob"}, meta=>{self.showCompressProgress(meta)}).then(function(content){
15638-
if (content) {
15639-
saveAs(content, packName);
15640-
}
15641-
callback();
15642-
})
15643-
}
15644-
}, "image/png");
15650+
self.showTips("Downloading "+(downloaded+1)+"/"+len, 1000000);
15651+
zip.file(imgName.replace(/^data:.*/, "img").replace(/\//g,""), blob);
15652+
downloaded++;
15653+
over && over();
15654+
if(downloaded == len){
15655+
self.showTips(`Begin compress to ${packName}...`, 100000);
15656+
zip.generateAsync({type:"blob"}, meta=>{self.showCompressProgress(meta)}).then(function(content){
15657+
if (content) {
15658+
saveAs(content, packName);
15659+
}
15660+
callback();
15661+
})
15662+
}
1564515663
});
1564615664
}else{
1564715665
crosHandler(imgSrc);
@@ -16190,29 +16208,6 @@ ImgOps | https://imgops.com/#b#`;
1619016208
this.bricksInstance.resize(true);
1619116209
}
1619216210
},
16193-
dataURLToCanvas:function (dataurl, cb){
16194-
if(!dataurl)return cb(null);
16195-
var ctx = canvas.getContext('2d');
16196-
var img = new Image();
16197-
img.setAttribute("crossOrigin","anonymous");
16198-
img.onload = function(){
16199-
canvas.width = img.width;
16200-
canvas.height = img.height;
16201-
ctx.clearRect(0, 0, canvas.width, canvas.height);
16202-
ctx.drawImage(img, 0, 0);
16203-
cb(canvas);
16204-
};
16205-
img.onerror = function(){
16206-
cb(null);
16207-
};
16208-
img.src = dataurl;
16209-
},
16210-
blobToCanvas: function (blob, cb){
16211-
var self=this;
16212-
blobToDataURL(blob, function (dataurl){
16213-
self.dataURLToCanvas(dataurl, cb);
16214-
});
16215-
},
1621616211
showHideBottom: function() { // 显示隐藏 sidebar-container
1621716212
var sidebarContainer = this.eleMaps['sidebar-container'],
1621816213
isHidden = sidebarContainer.style.visibility == 'hidden';

0 commit comments

Comments
 (0)