|
12 | 12 | // @description:ja 画像を強力に閲覧できるツール。ポップアップ表示、拡大・縮小、回転、一括保存などの機能を自動で実行できます
|
13 | 13 | // @description:pt-BR Poderosa ferramenta de visualização de imagens on-line, que pode pop-up/dimensionar/girar/salvar em lote imagens automaticamente
|
14 | 14 | // @description:ru Мощный онлайн-инструмент для просмотра изображений, который может автоматически отображать/масштабировать/вращать/пакетно сохранять изображения
|
15 |
| -// @version 2025.7.5.1 |
| 15 | +// @version 2025.7.22.1 |
16 | 16 | // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAAV1BMVEUAAAD////29vbKysoqKioiIiKysrKhoaGTk5N9fX3z8/Pv7+/r6+vk5OTb29vOzs6Ojo5UVFQzMzMZGRkREREMDAy4uLisrKylpaV4eHhkZGRPT08/Pz/IfxjQAAAAgklEQVQoz53RRw7DIBBAUb5pxr2m3/+ckfDImwyJlL9DDzQgDIUMRu1vWOxTBdeM+onApENF0qHjpkOk2VTwLVEF40Kbfj1wK8AVu2pQA1aBBYDHJ1wy9Cf4cXD5chzNAvsAnc8TjoLAhIzsBao9w1rlVTIvkOYMd9nm6xPi168t9AYkbANdajpjcwAAAABJRU5ErkJggg==
|
17 | 17 | // @namespace https://github.com/hoothin/UserScripts
|
18 | 18 | // @homepage https://github.com/hoothin/UserScripts/tree/master/Picviewer%20CE%2B
|
@@ -12226,6 +12226,22 @@ ImgOps | https://imgops.com/#b#`;
|
12226 | 12226 | };
|
12227 | 12227 | img.src = dataurl;
|
12228 | 12228 | }
|
| 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 | + } |
12229 | 12245 | var cookie;
|
12230 | 12246 | function urlToBlob(url, cb, forcePng, tryTimes = 0) {
|
12231 | 12247 | tryTimes++;
|
@@ -12255,8 +12271,12 @@ ImgOps | https://imgops.com/#b#`;
|
12255 | 12271 | a.readAsDataURL(blob);
|
12256 | 12272 | a.onload = function (e) {
|
12257 | 12273 | 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 | + } |
12260 | 12280 | }, "image/" + (conversion || "png"));
|
12261 | 12281 | });
|
12262 | 12282 | };
|
@@ -14533,7 +14553,7 @@ ImgOps | https://imgops.com/#b#`;
|
14533 | 14553 | let picName = (saveIndex < 10 ? "00" + saveIndex : (saveIndex < 100 ? "0" + saveIndex : saveIndex)) + (title ? "-" + title : ""), hostArr = location.host.split(".");
|
14534 | 14554 | let host = hostArr[hostArr.length-2];
|
14535 | 14555 | saveParams.push([node.dataset.src, picName]);
|
14536 |
| - if (node.dataset.srcs) { |
| 14556 | + if (node.dataset.srcs && node.dataset.srcs != node.dataset.src) { |
14537 | 14557 | node.dataset.srcs.split(",").forEach(src => {
|
14538 | 14558 | saveParams.push([src, picName]);
|
14539 | 14559 | });
|
@@ -15622,26 +15642,24 @@ ImgOps | https://imgops.com/#b#`;
|
15622 | 15642 | });
|
15623 | 15643 | }
|
15624 | 15644 | 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){ |
15628 | 15647 | crosHandler(imgSrc);
|
15629 | 15648 | return;
|
15630 | 15649 | }
|
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 | + } |
15645 | 15663 | });
|
15646 | 15664 | }else{
|
15647 | 15665 | crosHandler(imgSrc);
|
@@ -16190,29 +16208,6 @@ ImgOps | https://imgops.com/#b#`;
|
16190 | 16208 | this.bricksInstance.resize(true);
|
16191 | 16209 | }
|
16192 | 16210 | },
|
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 |
| - }, |
16216 | 16211 | showHideBottom: function() { // 显示隐藏 sidebar-container
|
16217 | 16212 | var sidebarContainer = this.eleMaps['sidebar-container'],
|
16218 | 16213 | isHidden = sidebarContainer.style.visibility == 'hidden';
|
|
0 commit comments