From 1d53897f2af16371530f7d0224f8db75973dcdce Mon Sep 17 00:00:00 2001 From: GrosPoulet Date: Fri, 11 Sep 2020 20:52:00 +0200 Subject: [PATCH] New plug-in for : WireImage --- manifest.json | 13 +++++++++++++ plugins/wireimage.js | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 plugins/wireimage.js diff --git a/manifest.json b/manifest.json index e898a1c2d..7083353f5 100644 --- a/manifest.json +++ b/manifest.json @@ -1449,6 +1449,19 @@ { "js": ["plugins/tuchong.js"], "matches": ["*://*.tuchong.com/*"] + }, + { + "js": ["plugins/wireimage.js"], + "matches": ["*://*.wireimage.com/*", + "*://*.wireimage.com.au/*", + "*://*.wireimage.de/*", + "*://*.wireimage.es/*", + "*://*.wireimage.co.in/*", + "*://*.wireimage.fr/*", + "*://*.wireimage.it/*", + "*://*.wireimage.jp/*", + "*://*.wireimage.com.pt/*", + "*://*.wireimage.se/*"] } ] } diff --git a/plugins/wireimage.js b/plugins/wireimage.js new file mode 100644 index 000000000..e0999b608 --- /dev/null +++ b/plugins/wireimage.js @@ -0,0 +1,37 @@ +var hoverZoomPlugins = hoverZoomPlugins || []; +hoverZoomPlugins.push({ + name:'wireimage.com', + version:'1.0', + prepareImgLinks:function (callback) { + + var res = []; + + hoverZoom.urlReplace(res, + 'img[src]', + /(.*)\?(.*)/, + '$1' + ); + + $('[style*=background]').each(function() { + // extract url from style + var backgroundImage = this.style.backgroundImage; + if (backgroundImage.indexOf("url") != -1) { + var reUrl = /.*url\s*\(\s*(.*)\s*\).*/i + backgroundImage = backgroundImage.replace(reUrl, '$1'); + // remove leading & trailing quotes + var backgroundImageUrl = backgroundImage.replace(/^['"]/,"").replace(/['"]+$/,""); + var fullsizeUrl = backgroundImageUrl.replace(/(.*)\?(.*)/, '$1'); + if (fullsizeUrl != backgroundImageUrl) { + var link = $(this); + if (link.data().hoverZoomSrc == undefined) { link.data().hoverZoomSrc = [] } + if (link.data().hoverZoomSrc.indexOf(fullsizeUrl) == -1) { + link.data().hoverZoomSrc.unshift(fullsizeUrl); + res.push(link); + } + } + } + }); + + callback($(res), this.name); + } +}); \ No newline at end of file