From e20a0e1abe47625f4dfa94b106428d109e91b524 Mon Sep 17 00:00:00 2001 From: lzrdblzzrd Date: Fri, 7 Oct 2022 16:11:09 +0300 Subject: [PATCH] Upload files to '' --- yohoho-watch.png | Bin 0 -> 704 bytes yohoho-watch.user.js | 113 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 yohoho-watch.png create mode 100644 yohoho-watch.user.js diff --git a/yohoho-watch.png b/yohoho-watch.png new file mode 100644 index 0000000000000000000000000000000000000000..43169c6dc8c044cb51ea2266a885ff1310571a11 GIT binary patch literal 704 zcmV;x0zdtUP)5i;F%W%Te7E}r_8&BVko757`;tQ_$(B-lXu<9| z1V#6f+R&Ur$vTHnic1|Ry?Xlx&L1Ry;QoMAMj9nrt#(@r=AxC}%)EIs+LqQDb*qpV zDi}*O&{F_BdsIN7fYnG~RRe*jgF+$&kShk&W#Ecw>nuAIC_=0x0zLz<-T@qZc71E_ z)@M*izdr=PzZD=gFjqEfw@-AV%~FgNG!4O* z($wLl&-W{j?=R8>O46kadzTW!gmoU{bpK8w{~^(3@Kkx3vXv-&Bd}3rHim6(q6(jE zq?(hZtn3>*7F8NqaW3FAiF9aF;ox|t{cBmJk>u>%=_N5x2DuNwX>UN3di%30i9H8? zDKXVSue5%hYaM`p7zx{v-)vEHudo9KU#YTG?-kIG$+z{h>|inSR6*<37I*D6Uj?Lw zN@EF6MYpjDIXx0ab`D@CaKcVlx9(s+bZ{fl4FHIa!C0WBfEOBAM1Y+Y3G?Zq$i8|- zhD0Dn9c z=(kzBnR*^}#Pg(v*9wJvzZ + + + + + + + +`; + +const BANNER_ID = 'yohoho-watch'; +const MOVIE_TYPES = ['film', 'series']; + +let currentMovieId = null; +let lastUrl = '/'; + +function openPlayer() { + if (!currentMovieId) return; + const link = new URL('https://4h0y.gitlab.io/'); + link.hash = currentMovieId; + window.open(link.toString(), '_blank').focus(); +} + +function mountBanner() { + const banner = document.createElement('div'); + banner.id = BANNER_ID; + banner.innerHTML = BANNER_IMAGE; + banner.style.width = '32px'; + banner.style.height = '128px'; + banner.style.top = '-128px'; + banner.style.left = '8px'; + banner.style.outline = 'none'; + banner.style.cursor = 'pointer'; + banner.style.position = 'fixed'; + banner.style.zIndex = '9000'; + banner.style.transition = 'top 0.2s ease'; + + banner.addEventListener('click', () => openPlayer()); + banner.addEventListener('mouseover', () => { banner.style.top = '-24px' }); + banner.addEventListener('mouseout', () => { banner.style.top = '-32px' }); + + setTimeout(() => { banner.style.top = '-32px' }, 1000); + + document.body.appendChild(banner); +} + +function unmountBanner() { + const banner = document.getElementById(BANNER_ID); + if (banner) banner.remove(); +} + +function updateBanner() { + const url = location.href; + + if (url === lastUrl) return; + lastUrl = url; + + const banner = document.getElementById(BANNER_ID); + const urlData = url.split('/'); + const movieId = urlData[4]; + const movieType = urlData[3]; + + if (!movieId || !movieType || !MOVIE_TYPES.includes(movieType)) { + if (banner) unmountBanner(); + currentMovieId = null; + } else { + if (!banner) mountBanner(); + currentMovieId = movieId; + } + +} + +/** + * Script initialization + */ +function init() { + const observer = new MutationObserver(() => updateBanner()); + observer.observe(document, { subtree: true, childList: true }); + + updateBanner(); + console.log('Yohoho Watch started! 🎥'); +} + +init();