111 lines
4.2 KiB
JavaScript
111 lines
4.2 KiB
JavaScript
// ==UserScript==
|
||
// @name Yohoho Watch
|
||
// @namespace https://gitea.lzrdblzzrd.xyz/lzrdblzzrd/Yohoho-Watch
|
||
// @author lzrdblzzrd
|
||
// @description Смотрите фильмы с Kinopoisk.ru на Yohoho бесплатно!
|
||
// @downloadURL https://gitea.lzrdblzzrd.xyz/lzrdblzzrd/Yohoho-Watch/raw/branch/master/yohoho-watch.user.js
|
||
// @updateURL https://gitea.lzrdblzzrd.xyz/lzrdblzzrd/Yohoho-Watch/raw/branch/master/yohoho-watch.user.js
|
||
// @icon https://gitea.lzrdblzzrd.xyz/lzrdblzzrd/Yohoho-Watch/raw/branch/master/yohoho-watch.png
|
||
// @version 1.1
|
||
// @match *://www.kinopoisk.ru/*
|
||
// @run-at document-end
|
||
// ==/UserScript==
|
||
|
||
const BANNER_IMAGE = `<?xml version="1.0" encoding="utf-8"?>
|
||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||
viewBox="0 0 128 512" style="enable-background:new 0 0 128 512;" xml:space="preserve">
|
||
<style type="text/css">
|
||
.st0{fill-rule:evenodd;clip-rule:evenodd;fill:url(#Banner_00000055666303498189408720000007536872097726533817_);}
|
||
.st1{fill-rule:evenodd;clip-rule:evenodd;fill:#FFFFFF;}
|
||
</style>
|
||
<linearGradient id="Banner_00000155117140210213162780000010184992392248604604_" gradientUnits="userSpaceOnUse" x1="-96" y1="96" x2="224" y2="416">
|
||
<stop offset="0" style="stop-color:#BF80FF"/>
|
||
<stop offset="1" style="stop-color:#8080FF"/>
|
||
</linearGradient>
|
||
<path id="Banner" style="fill-rule:evenodd;clip-rule:evenodd;fill:url(#Banner_00000155117140210213162780000010184992392248604604_);" d="
|
||
M128,0H0v512l64-32l64,32V0z"/>
|
||
<g id="icon" transform="matrix(1, 0, 0, 1, -64, 0)">
|
||
<path class="st1" d="M173.1,432.4c-9.1,24.9-36.6,37.7-61.5,28.7c-24.9-9.1-37.7-36.6-28.7-61.5c9.1-24.9,36.6-37.7,61.5-28.7
|
||
C169.3,380,182.2,407.5,173.1,432.4z M133.6,418.1c1.1-3.1-0.5-6.6-3.6-7.7c-3.1-1.1-6.6,0.5-7.7,3.6c-1.1,3.1,0.5,6.6,3.6,7.7
|
||
C129.1,422.8,132.5,421.2,133.6,418.1z M116.2,430.9c2.3-6.2-0.9-13.1-7.2-15.4c-6.2-2.3-13.1,0.9-15.4,7.2
|
||
c-2.3,6.2,0.9,13.1,7.2,15.4C107.1,440.3,113.9,437.1,116.2,430.9z M128.5,397c2.3-6.2-0.9-13.1-7.2-15.4
|
||
c-6.2-2.3-13.1,0.9-15.4,7.2c-2.3,6.2,0.9,13.1,7.2,15.4C119.4,406.5,126.3,403.3,128.5,397z M162.3,409.3
|
||
c2.3-6.2-0.9-13.1-7.2-15.4c-6.2-2.3-13.1,0.9-15.4,7.2c-2.3,6.2,0.9,13.1,7.2,15.4C153.2,418.8,160.1,415.6,162.3,409.3z
|
||
M150,443.2c2.3-6.2-0.9-13.1-7.2-15.4c-6.2-2.3-13.1,0.9-15.4,7.2c-2.3,6.2,0.9,13.1,7.2,15.4C140.9,452.6,147.8,449.4,150,443.2z
|
||
"/>
|
||
</g>
|
||
</svg>`;
|
||
|
||
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.title = 'Смотреть на Yohoho'
|
||
|
||
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;
|
||
}
|
||
|
||
}
|
||
|
||
function init() {
|
||
const observer = new MutationObserver(() => updateBanner());
|
||
observer.observe(document, { subtree: true, childList: true });
|
||
|
||
updateBanner();
|
||
console.log('Yohoho Watch started! 🎥');
|
||
}
|
||
|
||
init();
|