Skip to content

Commit 4103776

Browse files
authored
New plug-in for: ui.cn & jike.ui.cn (#1576) (#1616)
1 parent 38b39be commit 4103776

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

manifest.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,6 +2184,10 @@
21842184
{
21852185
"js": ["plugins/civitai.js"],
21862186
"matches": ["*://*.civitai.com/*", "*://*.civitai.green/*"]
2187+
},
2188+
{
2189+
"js": ["plugins/jike.js"],
2190+
"matches": ["*://*.ui.cn/*"]
21872191
}
21882192
]
21892193
}

plugins/jike.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
var hoverZoomPlugins = hoverZoomPlugins || [];
2+
hoverZoomPlugins.push({
3+
name:'jike',
4+
version:'0.1',
5+
prepareImgLinks:function (callback) {
6+
var pluginName = this.name;
7+
var res = [];
8+
9+
// https://imgjike.ui.cn/data/singles/9382d37a6bf01fa9f68fc952ae55e60c.png?imageView/1/w/230/h/498
10+
// => https://imgjike.ui.cn/data/singles/9382d37a6bf01fa9f68fc952ae55e60c.png
11+
// https://imgavater.ui.cn/avatar/1/5/8/3/1903851.jpg?imageMogr2/auto-orient/crop/!840x840a54a3/thumbnail/60x60
12+
// => https://imgavater.ui.cn/avatar/1/5/8/3/1903851.jpg
13+
14+
$('img[src*="/data/"], img[src*="/avatar/"]').one('mouseover', function() {
15+
const link = $(this);
16+
if (link.data().hoverZoomMouseOver) return;
17+
link.data().hoverZoomMouseOver = true;
18+
const src = this.src;
19+
const fullsizeUrl = src.replace(/(.*)\?.*/, '$1');
20+
21+
if (link.data().hoverZoomSrc == undefined) { link.data().hoverZoomSrc = [] }
22+
if (link.data().hoverZoomSrc.indexOf(fullsizeUrl) == -1) {
23+
link.data().hoverZoomSrc.unshift(fullsizeUrl);
24+
link.data().hoverZoomJikeImgUrl = fullsizeUrl;
25+
}
26+
27+
callback(link, pluginName);
28+
// Image or video is displayed iff the cursor is still over the link
29+
if (link.data().hoverZoomMouseOver)
30+
hoverZoom.displayPicFromElement(link);
31+
32+
}).one('mouseleave', function() {
33+
const link = $(this);
34+
link.data().hoverZoomMouseOver = false;
35+
});
36+
37+
callback($(res), this.name);
38+
}
39+
});

0 commit comments

Comments
 (0)