Update 'yohoho-watch.user.js'
This commit is contained in:
@@ -1,113 +1,110 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Yohoho Watch
|
// @name Yohoho Watch
|
||||||
// @namespace yohoho-watch
|
// @namespace yohoho-watch
|
||||||
// @author lzrdblzzrd
|
// @author lzrdblzzrd
|
||||||
// @description Watch films from Kinopoisk.ru on Yohoho for free!
|
// @description Watch films from Kinopoisk.ru on Yohoho for free!
|
||||||
// @downloadURL https://gitea.lzrdblzzrd.xyz/lzrdblzzrd/Yohoho-Watch/raw/branch/master/yohoho-watch.user.js
|
// @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
|
// @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
|
// @icon https://gitea.lzrdblzzrd.xyz/lzrdblzzrd/Yohoho-Watch/raw/branch/master/yohoho-watch.png
|
||||||
// @version 1.0
|
// @version 1.0
|
||||||
// @match *://www.kinopoisk.ru/*
|
// @match *://www.kinopoisk.ru/*
|
||||||
// @grant none
|
// @grant none
|
||||||
// @run-at document-end
|
// @run-at document-end
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
const BANNER_IMAGE = `<?xml version="1.0" encoding="utf-8"?>
|
const BANNER_IMAGE = `<?xml version="1.0" encoding="utf-8"?>
|
||||||
<svg version="1.1" id="Слой_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
<svg version="1.1" id="Слой_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">
|
viewBox="0 0 128 512" style="enable-background:new 0 0 128 512;" xml:space="preserve">
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
.st0{fill-rule:evenodd;clip-rule:evenodd;fill:url(#Banner_00000055666303498189408720000007536872097726533817_);}
|
.st0{fill-rule:evenodd;clip-rule:evenodd;fill:url(#Banner_00000055666303498189408720000007536872097726533817_);}
|
||||||
.st1{fill-rule:evenodd;clip-rule:evenodd;fill:#FFFFFF;}
|
.st1{fill-rule:evenodd;clip-rule:evenodd;fill:#FFFFFF;}
|
||||||
</style>
|
</style>
|
||||||
<linearGradient id="Banner_00000155117140210213162780000010184992392248604604_" gradientUnits="userSpaceOnUse" x1="-96" y1="96" x2="224" y2="416">
|
<linearGradient id="Banner_00000155117140210213162780000010184992392248604604_" gradientUnits="userSpaceOnUse" x1="-96" y1="96" x2="224" y2="416">
|
||||||
<stop offset="0" style="stop-color:#BF80FF"/>
|
<stop offset="0" style="stop-color:#BF80FF"/>
|
||||||
<stop offset="1" style="stop-color:#8080FF"/>
|
<stop offset="1" style="stop-color:#8080FF"/>
|
||||||
</linearGradient>
|
</linearGradient>
|
||||||
<path id="Banner" style="fill-rule:evenodd;clip-rule:evenodd;fill:url(#Banner_00000155117140210213162780000010184992392248604604_);" d="
|
<path id="Banner" style="fill-rule:evenodd;clip-rule:evenodd;fill:url(#Banner_00000155117140210213162780000010184992392248604604_);" d="
|
||||||
M128,0H0v512l64-32l64,32V0z"/>
|
M128,0H0v512l64-32l64,32V0z"/>
|
||||||
<g id="icon" transform="matrix(1, 0, 0, 1, -64, 0)">
|
<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
|
<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
|
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
|
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-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
|
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
|
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
|
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>
|
</g>
|
||||||
</svg>`;
|
</svg>`;
|
||||||
|
|
||||||
const BANNER_ID = 'yohoho-watch';
|
const BANNER_ID = 'yohoho-watch';
|
||||||
const MOVIE_TYPES = ['film', 'series'];
|
const MOVIE_TYPES = ['film', 'series'];
|
||||||
|
|
||||||
let currentMovieId = null;
|
let currentMovieId = null;
|
||||||
let lastUrl = '/';
|
let lastUrl = '/';
|
||||||
|
|
||||||
function openPlayer() {
|
function openPlayer() {
|
||||||
if (!currentMovieId) return;
|
if (!currentMovieId) return;
|
||||||
const link = new URL('https://4h0y.gitlab.io/');
|
const link = new URL('https://4h0y.gitlab.io/');
|
||||||
link.hash = currentMovieId;
|
link.hash = currentMovieId;
|
||||||
window.open(link.toString(), '_blank').focus();
|
window.open(link.toString(), '_blank').focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
function mountBanner() {
|
function mountBanner() {
|
||||||
const banner = document.createElement('div');
|
const banner = document.createElement('div');
|
||||||
banner.id = BANNER_ID;
|
banner.id = BANNER_ID;
|
||||||
banner.innerHTML = BANNER_IMAGE;
|
banner.innerHTML = BANNER_IMAGE;
|
||||||
banner.style.width = '32px';
|
banner.style.width = '32px';
|
||||||
banner.style.height = '128px';
|
banner.style.height = '128px';
|
||||||
banner.style.top = '-128px';
|
banner.style.top = '-128px';
|
||||||
banner.style.left = '8px';
|
banner.style.left = '8px';
|
||||||
banner.style.outline = 'none';
|
banner.style.outline = 'none';
|
||||||
banner.style.cursor = 'pointer';
|
banner.style.cursor = 'pointer';
|
||||||
banner.style.position = 'fixed';
|
banner.style.position = 'fixed';
|
||||||
banner.style.zIndex = '9000';
|
banner.style.zIndex = '9000';
|
||||||
banner.style.transition = 'top 0.2s ease';
|
banner.style.transition = 'top 0.2s ease';
|
||||||
|
|
||||||
banner.addEventListener('click', () => openPlayer());
|
banner.addEventListener('click', () => openPlayer());
|
||||||
banner.addEventListener('mouseover', () => { banner.style.top = '-24px' });
|
banner.addEventListener('mouseover', () => { banner.style.top = '-24px' });
|
||||||
banner.addEventListener('mouseout', () => { banner.style.top = '-32px' });
|
banner.addEventListener('mouseout', () => { banner.style.top = '-32px' });
|
||||||
|
|
||||||
setTimeout(() => { banner.style.top = '-32px' }, 1000);
|
setTimeout(() => { banner.style.top = '-32px' }, 1000);
|
||||||
|
|
||||||
document.body.appendChild(banner);
|
document.body.appendChild(banner);
|
||||||
}
|
}
|
||||||
|
|
||||||
function unmountBanner() {
|
function unmountBanner() {
|
||||||
const banner = document.getElementById(BANNER_ID);
|
const banner = document.getElementById(BANNER_ID);
|
||||||
if (banner) banner.remove();
|
if (banner) banner.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateBanner() {
|
function updateBanner() {
|
||||||
const url = location.href;
|
const url = location.href;
|
||||||
|
|
||||||
if (url === lastUrl) return;
|
if (url === lastUrl) return;
|
||||||
lastUrl = url;
|
lastUrl = url;
|
||||||
|
|
||||||
const banner = document.getElementById(BANNER_ID);
|
const banner = document.getElementById(BANNER_ID);
|
||||||
const urlData = url.split('/');
|
const urlData = url.split('/');
|
||||||
const movieId = urlData[4];
|
const movieId = urlData[4];
|
||||||
const movieType = urlData[3];
|
const movieType = urlData[3];
|
||||||
|
|
||||||
if (!movieId || !movieType || !MOVIE_TYPES.includes(movieType)) {
|
if (!movieId || !movieType || !MOVIE_TYPES.includes(movieType)) {
|
||||||
if (banner) unmountBanner();
|
if (banner) unmountBanner();
|
||||||
currentMovieId = null;
|
currentMovieId = null;
|
||||||
} else {
|
} else {
|
||||||
if (!banner) mountBanner();
|
if (!banner) mountBanner();
|
||||||
currentMovieId = movieId;
|
currentMovieId = movieId;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
function init() {
|
||||||
* Script initialization
|
const observer = new MutationObserver(() => updateBanner());
|
||||||
*/
|
observer.observe(document, { subtree: true, childList: true });
|
||||||
function init() {
|
|
||||||
const observer = new MutationObserver(() => updateBanner());
|
updateBanner();
|
||||||
observer.observe(document, { subtree: true, childList: true });
|
console.log('Yohoho Watch started! 🎥');
|
||||||
|
}
|
||||||
updateBanner();
|
|
||||||
console.log('Yohoho Watch started! 🎥');
|
init();
|
||||||
}
|
|
||||||
|
|
||||||
init();
|
|
||||||
|
Reference in New Issue
Block a user