Skip to content

Commit

Permalink
Merge pull request #1084 from GrosPoulet/master
Browse files Browse the repository at this point in the history
New plug-in for: fandom.com (#1077)
  • Loading branch information
GrosPoulet authored Feb 11, 2023
2 parents 8a33f13 + 5b54127 commit 559d92e
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
4 changes: 4 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1872,6 +1872,10 @@
"matches": ["*://*.homeexchange.com/*",
"*://*.homeexchange.fr/*",
"*://*.homeexchange.it/*"]
},
{
"js": ["plugins/fandom.js"],
"matches": ["*://*.fandom.com/*"]
}
]
}
79 changes: 79 additions & 0 deletions plugins/fandom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
var hoverZoomPlugins = hoverZoomPlugins || [];
hoverZoomPlugins.push({
name:'fandom',
version:'0.1',
prepareImgLinks:function (callback) {

// sample: https://static.wikia.nocookie.net/supernaturalpowers/images/3/34/%EB%A7%88%EB%B8%94_%EC%9D%B4%ED%84%B0%EB%8B%88%ED%8B%B0.jpg/revision/latest/zoom-crop/width/500/height/500?cb=20190426134645&path-prefix=ko
// full: https://static.wikia.nocookie.net/supernaturalpowers/images/3/34/%EB%A7%88%EB%B8%94_%EC%9D%B4%ED%84%B0%EB%8B%88%ED%8B%B0.jpg/revision/latest/?cb=20190426134645&path-prefix=ko

$('img[src*="nocookie"], div[src*="nocookie"], a[href*="nocookie"]').one('mouseover', function() {
let link = $(this);
const src = this.src || this.href;
const fullsize = src.replace(/\/(zoom|scale|smart|thumbnail)([^\?]{1,})(.*)/, '$3');
link.data().hoverZoomSrc = [fullsize];
link.addClass('hoverZoomLink');
hoverZoom.displayPicFromElement(link);
});

$('[style*=url]').filter(function() { return !(/\/poster\.jpg/.test(this.style.backgroundImage)) }).one('mouseover', function() {
let link = $(this);
// extract url from style
let backgroundImage = this.style.backgroundImage;
const reUrl = /.*url\s*\(\s*(.*)\s*\).*/i
backgroundImage = backgroundImage.replace(reUrl, '$1');
// remove leading & trailing quotes
const src = backgroundImage.replace(/^['"]/, "").replace(/['"]+$/, "");
const fullsize = src.replace(/\/(zoom|scale|smart|thumbnail)([^\?]{1,})(.*)/, '$3');
link.data().hoverZoomSrc = [fullsize];
link.addClass('hoverZoomLink');
hoverZoom.displayPicFromElement(link);
});

// videos

// sample: https://www.fandom.com/video/t7eezF6p/honest-game-trailers-valheim
// playlist: https://cdn.jwplayer.com/manifests/t7eezF6p.m3u8

$('a[href*="/video/"]').one('mouseover', function() {
let link = $(this);
const href = this.href;
const re = /\/video\/(.*?)\//;
const m = href.match(re);
if (m == null) return;
const videoId = m[1];
const videoUrl = `https://cdn.jwplayer.com/manifests/${videoId}.m3u8`;
link.data().hoverZoomSrc = [videoUrl];
link.addClass('hoverZoomLink');
hoverZoom.displayPicFromElement(link);
});

$('div[data-video-id]').one('mouseover', function() {
let link = $(this);
const videoId = this.dataset.videoId;
const videoUrl = `https://cdn.jwplayer.com/manifests/${videoId}.m3u8`;
link.data().hoverZoomSrc = [videoUrl];
link.addClass('hoverZoomLink');
hoverZoom.displayPicFromElement(link);
});

$('[style*=url]').filter(function() { return (/\/poster\.jpg/.test(this.style.backgroundImage)) }).one('mouseover', function() {
let link = $(this);
// extract url from style
let backgroundImage = this.style.backgroundImage;
const reUrl = /.*url\s*\(\s*(.*)\s*\).*/i
backgroundImage = backgroundImage.replace(reUrl, '$1');
// remove leading & trailing quotes
const src = backgroundImage.replace(/^['"]/, "").replace(/['"]+$/, "");
const re = /\/([^\/]{1,})\/poster/
const m = src.match(re);
if (m == null) return;
const videoId = m[1];
const videoUrl = `https://cdn.jwplayer.com/manifests/${videoId}.m3u8`;
link.data().hoverZoomSrc = [videoUrl];
link.addClass('hoverZoomLink');
hoverZoom.displayPicFromElement(link);
});

}
});

0 comments on commit 559d92e

Please sign in to comment.