Skip to content

Commit 03e972c

Browse files
committed
Update Picviewer CE+.user.js
1 parent 8644316 commit 03e972c

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

Picviewer CE+/Picviewer CE+.user.js

Lines changed: 30 additions & 4 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 2026.1.23.1
15+
// @version 2026.1.31.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://pv.hoothin.com/
@@ -12400,7 +12400,7 @@ ImgOps | https://imgops.com/#b#`;
1240012400
}
1240112401
function urlToBlobWithFetch(urlString, cb){
1240212402
fetch(urlString).then(response => response.blob()).then(blob => {
12403-
let ext = blob.type.replace(/.*image\/([\w\-]+).*/, "$1");
12403+
let ext = extFromMimeAndUrl(blob.type, urlString);
1240412404
if (ext && ext.indexOf("text/html") === 0 && (blob.size || 0) < 1000) return cb(null, '');
1240512405
if (ext === "none") ext = "webp";
1240612406
let conversion = formatDict.get(ext);
@@ -12577,6 +12577,23 @@ ImgOps | https://imgops.com/#b#`;
1257712577
return "";
1257812578
}
1257912579
var cookie;
12580+
function extFromMimeAndUrl(mimeType, url) {
12581+
let ext = '';
12582+
if (mimeType) {
12583+
const cleanMime = mimeType.split(';')[0].trim().toLowerCase();
12584+
if (cleanMime.indexOf('image/') === 0) {
12585+
ext = cleanMime.slice(6);
12586+
} else if (cleanMime.indexOf('text/html') === 0) {
12587+
ext = 'text/html';
12588+
}
12589+
}
12590+
if (!ext) {
12591+
const m = String(url || '').match(/\.([a-z0-9]+)(?:$|[?#])/i);
12592+
ext = m ? m[1].toLowerCase() : '';
12593+
}
12594+
if (ext.indexOf('/') !== -1) ext = '';
12595+
return ext;
12596+
}
1258012597
function urlToBlob(url, cb, forcePng, tryTimes = 0) {
1258112598
tryTimes++;
1258212599
if (tryTimes > 3) {
@@ -12596,7 +12613,7 @@ ImgOps | https://imgops.com/#b#`;
1259612613
onload: function(d) {
1259712614
let blob = d.response;
1259812615
if (!blob.type) return urlToBlob(url, cb, forcePng, tryTimes);
12599-
let ext = blob.type.replace(/.*image\/([\w\-]+).*/, "$1");
12616+
let ext = extFromMimeAndUrl(blob.type, url);
1260012617
if (ext && ext.indexOf("text/html") === 0 && (blob.size || 0) < 100000) {
1260112618
urlToBlobWithFetch(url, cb);
1260212619
return;
@@ -24756,7 +24773,7 @@ ImgOps | https://imgops.com/#b#`;
2475624773
},'*');
2475724774
};
2475824775

24759-
if(this.openInTopWindow && isFrame && topWindowValid!==false && buttonType!='magnifier'){
24776+
if(this.openInTopWindow && isFrame && topWindowValid!==false && buttonType!='magnifier' && !isLargeFrame()){
2476024777
if(topWindowValid){
2476124778
openInTop();
2476224779
}else{//先发消息问问顶层窗口是不是非frameset窗口
@@ -26133,6 +26150,15 @@ ImgOps | https://imgops.com/#b#`;
2613326150
};
2613426151

2613526152
var isFrame=window!=window.parent;
26153+
function isLargeFrame(){
26154+
try{
26155+
var topWin = window.top;
26156+
return window.innerWidth >= topWin.innerWidth * 0.5 &&
26157+
window.innerHeight >= topWin.innerHeight * 0.5;
26158+
}catch(e){
26159+
return false;
26160+
}
26161+
}
2613626162
var topWindowValid;
2613726163
var frameSentData;
2613826164
var frameSentSuccessData;

0 commit comments

Comments
 (0)