From 6a27a1838c3327a72afb7d7b1a650311c1e51194 Mon Sep 17 00:00:00 2001 From: GrosPoulet Date: Sun, 31 Mar 2024 20:30:22 +0200 Subject: [PATCH] New plug-in for: cineserie.com --- manifest.json | 6 +++++- plugins/cineserie.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 plugins/cineserie.js diff --git a/manifest.json b/manifest.json index 5a5722cce..56f2c7617 100644 --- a/manifest.json +++ b/manifest.json @@ -2028,6 +2028,10 @@ { "js": ["plugins/onzemondial.js"], "matches": ["*://*.onzemondial.com/*"] - } + }, + { + "js": ["plugins/cineserie.js"], + "matches": ["*://*.cineserie.com/*"] + } ] } diff --git a/plugins/cineserie.js b/plugins/cineserie.js new file mode 100644 index 000000000..678c261cd --- /dev/null +++ b/plugins/cineserie.js @@ -0,0 +1,42 @@ +var hoverZoomPlugins = hoverZoomPlugins || []; +hoverZoomPlugins.push({ + name:'cineserie', + version:'0.1', + prepareImgLinks:function (callback) { + var res = []; + + // sample: https://imgr.cineserie.com/2016/05/143726.jpg?imgeng=/f_jpg/cmpr_0/w_225/h_337/m_cropbox&ver=1 + // -> https://imgr.cineserie.com/2016/05/143726.jpg + + function findFullsizeUrl(link, src) { + let fullsizeUrl = src.replace(/(png|jpe?g)\?.*/, '$1'); + if (fullsizeUrl == src) return; + + if (link.data().hoverZoomSrc == undefined) { link.data().hoverZoomSrc = [] } + if (link.data().hoverZoomSrc.indexOf(fullsizeUrl) == -1) { + link.data().hoverZoomSrc.unshift(fullsizeUrl); + res.push(link); + } + } + + $('img[src*="png?"], img[src*="jpg?"], img[src*="jpeg?"]').each(function() { + findFullsizeUrl($(this), this.src); + }); + + $('[style*="png?"], [style*="jpg?"], [style*="jpeg?"]').each(function() { + // extract url from style + var backgroundImage = this.style.backgroundImage; + if (backgroundImage && /png|jpe?g/.test(backgroundImage)) { + const reUrl = /.*url\s*\(\s*(.*)\s*\).*/i + backgroundImage = backgroundImage.replace(reUrl, '$1'); + // remove leading & trailing quotes + var backgroundImageUrl = backgroundImage.replace(/^['"]/, '').replace(/['"]+$/, ''); + findFullsizeUrl($(this), backgroundImageUrl); + } + }); + + if (res.length) { + callback($(res), this.name); + } + } +});