Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New plug-in for: fandom.com (#1077) #1084

Merged
merged 1 commit into from
Feb 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});

}
});