Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name КиноКлик
- // @namespace https://greasyfork.org/ru/scripts/558634-киноклик
- // @author 4c5688
- // @license CC BY-SA
- // @version 1.1
- // @description Добавляет кнопки для просмотра и поиска на популярных трекерах фильмов и сериалов (отказоустойчиво)
- // @match *://*.kinopoisk.ru/*
- // @grant none
- // @icon https://www.kinopoisk.ru/favicon.ico
- // @downloadURL https://update.greasyfork.org/scripts/558634/%D0%9A%D0%B8%D0%BD%D0%BE%D0%9A%D0%BB%D0%B8%D0%BA.user.js
- // @updateURL https://update.greasyfork.org/scripts/558634/%D0%9A%D0%B8%D0%BD%D0%BE%D0%9A%D0%BB%D0%B8%D0%BA.meta.js
- // ==/UserScript==
- (function() {
- 'use strict';
- const SAFE_RESOURCES = [
- { title: "SSpoisk", url: "http://flcksbr.top/film/%id/", icon: "https://favicon.yandex.net/favicon/kinopoisk.ru" },
- { title: "Kinobox", url: "https://kinohost.web.app/movie/%id/", icon: "https://favicon.yandex.net/favicon/kinobox.tv" },
- { title: "YouTube", url: "https://www.youtube.com/results?search_query=%text %year", icon: "https://favicon.yandex.net/favicon/youtube.com" },
- { title: "VKVideo", url: "https://vkvideo.ru/?q=%text %year", icon: "https://favicon.yandex.net/favicon/vkvideo.ru" },
- { title: "Rutube", url: "https://rutube.ru/search/?query=%text %year", icon: "https://favicon.yandex.net/favicon/rutube.ru" },
- { title: "MyMail Video", url: "https://my.mail.ru/video/search?q=%text %year", icon: "https://favicon.yandex.net/favicon/my.mail.ru" },
- { title: "Flixomo", url: "https://flixmomo.org/search?q=%text", icon: "https://favicon.yandex.net/favicon/flixmomo.org" },
- { title: "Rutracker", url: "https://rutracker.net/forum/tracker.php?nm=%text %year", icon: "https://favicon.yandex.net/favicon/rutracker.net" },
- { title: "Rutor", url: "https://rutor.org/search/0/0/100/0/%cleantext %year", icon: "https://favicon.yandex.net/favicon/rutor.org" },
- { title: "Kinozal", url: "https://kinozal.tv/browse.php?s=%text&d=%year", icon: "https://favicon.yandex.net/favicon/kinozal.tv" },
- { title: "NNMClub", url: "https://nnmclub.to/forum/tracker.php?nm=%text %year", icon: "https://favicon.yandex.net/favicon/nnmclub.to" },
- { title: "The Pirate Bay", url: "https://thepiratebay.org/search.php?q=%engcleantext %year", icon: "https://favicon.yandex.net/favicon/thepiratebay.org" },
- { title: "Nyaa", url: "https://nyaa.land/?f=0&c=0_0&q=%text", icon: "https://favicon.yandex.net/favicon/nyaa.land" },
- ];
- const QUERY_DATA = {};
- function cleanQuery(str, lang='ru') {
- if(!str) return "";
- const stop = lang==='ru' ? ["в","во","на","по","и","с","со","к","ко","за","из","у","для","от","до","о","об","а"] : [];
- const regex = lang==='ru' ? /[^а-яё0-9\s]/gi : /[^a-z0-9\s]/gi;
- return str.toLowerCase()
- .replace(regex," ")
- .split(/\s+/)
- .filter(w => w.length>2 && !stop.includes(w))
- .join(" ");
- }
- function querystring(str) {
- return str.replace(/%(\w+)/g, (_,w) => QUERY_DATA[w.toLowerCase()] ? encodeURIComponent(QUERY_DATA[w.toLowerCase()]) : _ );
- }
- function extractQueryData() {
- const h1 = document.querySelector('h1[itemprop="name"]');
- if(!h1) return;
- const titleSpan = h1.querySelector('span');
- const titleText = titleSpan ? titleSpan.textContent.trim() : '';
- const origSpan = document.querySelector('span[class*="OriginalTitle"], span[class*="originalTitle"]');
- const engTitle = origSpan && origSpan.textContent.trim() ? origSpan.textContent.trim() : titleText;
- const yearMatch = titleText.match(/\((\d{4})\)/);
- const year = yearMatch ? yearMatch[1] : '';
- const idMatch = location.pathname.match(/\/(film|series)\/(\d+)/);
- const id = idMatch ? idMatch[2] : '';
- QUERY_DATA.text = titleText.replace(/\(\d{4}\)/, '').trim();
- QUERY_DATA.engtext = engTitle;
- QUERY_DATA.year = year;
- QUERY_DATA.id = id;
- QUERY_DATA.cleantext = cleanQuery(QUERY_DATA.text, 'ru');
- QUERY_DATA.engcleantext = cleanQuery(QUERY_DATA.engtext, 'en');
- }
- const style=document.createElement('style');
- style.textContent=`
- button.kinopoisk-watch-online-button,
- .styles_subscriptionOffer__eau7V,
- .styles_root__J2PUZ,
- .styles_hdMetaTableContainer__coI3m,
- .styles_watchingServices__EeMSa,
- .styles_plusBadgeCounter__ztZqV,
- .style_root__UUsUH.style_container__gsfKM { display:none!important; }
- .kp-alt-wrapper { margin-top:6px; position:relative; display:inline-block; width:100%; }
- .kp-alt-body {
- position:absolute;
- top:calc(100% + 6px);
- left:0;
- transform-origin:top;
- transform:scaleY(0);
- border-radius:10px;
- padding:10px;
- display:flex;
- flex-direction:column;
- box-shadow:0 4px 12px rgba(0,0,0,.15);
- transition: transform .25s ease;
- z-index:100;
- background:rgba(255,255,255,0.98);
- width: max-content;
- min-width:200px;
- }
- .kp-alt-body.open { transform:scaleY(1); }
- .kp-row {
- display:flex;
- align-items:center;
- gap:10px;
- padding:8px 12px;
- border-radius:8px;
- cursor:pointer;
- transition:background .2s, transform .15s;
- }
- .kp-row:hover { background:rgba(0,0,0,0.08); transform:scale(1.03); }
- .kp-row a { color:inherit!important; text-decoration:none; font-size:16px; font-weight:500; }
- `;
- document.head.appendChild(style);
- let lastUrl = location.href;
- const observer = new MutationObserver(()=>{
- const urlChanged = location.href !== lastUrl;
- if(urlChanged) { lastUrl = location.href; extractQueryData(); }
- let watchBtn = document.getElementById("rk-watch-btn");
- if(!watchBtn){
- const originalBtn = document.querySelector("button[title='Буду смотреть']");
- const buttonRoot = originalBtn?.closest("div");
- if(originalBtn && buttonRoot?.parentElement && QUERY_DATA.id){
- const wrapper=document.createElement("div");
- wrapper.className="kp-alt-wrapper";
- const newBtn=document.createElement("button");
- newBtn.id="rk-watch-btn";
- newBtn.textContent="Смотреть онлайн";
- newBtn.className="style_button__Awsrq style_buttonSize52__MBeHC style_buttonPrimary__Qn_9l";
- const body=document.createElement("div");
- body.className="kp-alt-body";
- SAFE_RESOURCES.forEach(site=>{
- const row=document.createElement("div");
- row.className="kp-row";
- row.innerHTML=`<img src="${site.icon}" width="20" height="20"><a href="${querystring(site.url)}" target="_blank">${site.title}</a>`;
- body.appendChild(row);
- });
- newBtn.onclick = (e)=>{
- e.stopPropagation();
- body.classList.toggle("open");
- };
- document.addEventListener("click", e=>{
- if(!wrapper.contains(e.target)){
- body.classList.remove("open");
- }
- });
- wrapper.appendChild(newBtn);
- wrapper.appendChild(body);
- buttonRoot.parentElement.insertBefore(wrapper, buttonRoot.nextSibling);
- }
- }
- });
- observer.observe(document.body,{childList:true,subtree:true});
- extractQueryData();
- })();
Add Comment
Please, Sign In to add comment