From 8e881a271b68c324b22801066ade5da73198c0e9 Mon Sep 17 00:00:00 2001 From: GrosPoulet Date: Sun, 4 Feb 2024 14:46:12 +0100 Subject: [PATCH] New plug-in for: streamin.one (#1298) --- manifest.json | 1 + plugins/streaminone_a.js | 69 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 plugins/streaminone_a.js diff --git a/manifest.json b/manifest.json index af214a9f1..026b69b88 100644 --- a/manifest.json +++ b/manifest.json @@ -113,6 +113,7 @@ "plugins/sendvid_a.js", "plugins/squarespace_a.js", "plugins/streamable_a.js", + "plugins/streaminone_a.js", "plugins/tcgplayer_a.js", "plugins/tiktok_a.js", "plugins/tumblr_a.js", diff --git a/plugins/streaminone_a.js b/plugins/streaminone_a.js new file mode 100644 index 000000000..514367811 --- /dev/null +++ b/plugins/streaminone_a.js @@ -0,0 +1,69 @@ +var hoverZoomPlugins = hoverZoomPlugins || []; +hoverZoomPlugins.push( { + name: 'streaminone_a', + version: '1.0', + prepareImgLinks: function(callback) { + var name = this.name; + + // https://www.reddit.com/domain/streamin.one/ + // sample: https://streamin.one/v/bc63bf32 + // video: mp4 + $('a[href*="streamin.one/v/"], a[href*="streamin.me/v/"]').one('mouseover', function() { + var link = $(this); + var href = this.href; + if (link.data().hoverZoomMouseOver) return; + link.data().hoverZoomMouseOver = true; + + var videoId = undefined; + let m = href.match(/\/v\/([^\/\?]{1,})/); + if (m) { + videoId = m[1]; + } + + if (videoId == undefined) return; + + // reuse previous result + if (link.data().hoverZoomStreaminoneVideoId == videoId) { + if (link.data().hoverZoomStreaminoneSrc) { + link.data().hoverZoomSrc = [link.data().hoverZoomStreaminoneSrc]; + link.data().hoverZoomCaption = link.data().hoverZoomStreaminoneCaption; + } + return; + } + link.data().hoverZoomStreaminoneVideoId = videoId; + link.data().hoverZoomStreaminoneSrc = undefined; + link.data().hoverZoomStreaminoneCaption = undefined; + + // clean previous result + link.data().hoverZoomSrc = []; + link.data().hoverZoomCaption = undefined; + + // load link to extract fullsize url from document + hoverZoom.prepareFromDocument(link, href, function(doc, callback) { + const videoSrc = doc.head.querySelector('meta[property="og:video"]').content + '.video'; + const videoCaption = doc.head.querySelector('meta[property="og:description"]').content; + + let data = link.data(); + data.hoverZoomSrc = [videoSrc]; + data.hoverZoomCaption = videoCaption; + data.hoverZoomStreaminoneSrc = videoSrc; + data.hoverZoomStreaminoneCaption = videoCaption; + + callback(videoSrc); + // video is displayed iff the cursor is still over the link + if (data.hoverZoomMouseOver) + hoverZoom.displayPicFromElement(link); + return videoSrc; + }, true); // get source async + + // video is displayed iff the cursor is still over the link + if (link.data().hoverZoomMouseOver) + hoverZoom.displayPicFromElement(link); + + }).one('mouseleave', function () { + const link = $(this); + link.data().hoverZoomMouseOver = false; + }); + + } +});