Guest User

Найти фильм/сериал в ВК, RuTube или flcksbr

a guest
Sep 8th, 2025
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Найти фильм/сериал в ВК, RuTube или flcksbr — ФИНАЛЬНАЯ ВЕРСИЯ 2025
  3. // @namespace    http://tampermonkey.net/
  4. // @version      2.0 // Исправлено включение для сериалов
  5. // @description  Добавляет кнопки поиска фильма/сериала в ВК, RuTube и открытия на flcksbr через sspoisk.ru. Работает с фильмами и сериалами на Кинопоиске.
  6. // @author       @shittykitty_
  7. // @include      https://www.kinopoisk.ru/film/*
  8. // @include      https://www.kinopoisk.ru/series/*
  9. // @match        *://www.imdb.com/title/*
  10. // @grant        none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14.     'use strict';
  15.  
  16.     // Функция для получения селекторов в зависимости от сайта
  17.     function getSelectors() {
  18.         if (window.location.hostname.includes("kinopoisk.ru")) {
  19.             return [
  20.                 'span[data-tid="2da92aed"]', // Селектор для сериалов (2025)
  21.                 'span[data-tid="75209b22"]', // Селектор для фильмов (2025)
  22.                 '.film-header__title',
  23.                 '.film-page__title',
  24.                 'h1[itemprop="name"]',
  25.                 'h1',
  26.                 'span[itemprop="name"]'
  27.             ];
  28.         } else if (window.location.hostname.includes("imdb.com")) {
  29.             return [
  30.                 'h1[data-testid="hero__pageTitle"]',
  31.                 '.hero__primary-text',
  32.                 'h1[itemprop="name"]',
  33.                 'h1'
  34.             ];
  35.         }
  36.         return [];
  37.     }
  38.  
  39.     // Основная функция добавления кнопок
  40.     function addButton() {
  41.         let title = "";
  42.         let targetElement = null;
  43.         let filmId = null;
  44.  
  45.         const selectors = getSelectors();
  46.  
  47.         // Извлекаем ID фильма/сериала из URL (только для Кинопоиска)
  48.         // Исправлено: ищем ID как в /film/, так и в /series/
  49.         if (window.location.hostname.includes("kinopoisk.ru")) {
  50.             const match = window.location.pathname.match(/\/(?:film|series)\/(\d+)\//);
  51.             if (match) {
  52.                 filmId = match[1];
  53.             }
  54.         }
  55.  
  56.         // Ищем подходящий элемент заголовка
  57.         for (let sel of selectors) {
  58.             const el = document.querySelector(sel);
  59.             if (el && el.innerText.trim().length > 0) {
  60.                 title = el.innerText.trim();
  61.                 targetElement = el;
  62.                 break;
  63.             }
  64.         }
  65.  
  66.         if (!title || !targetElement) {
  67.             // Если элемент не найден, выходим.
  68.             return;
  69.         }
  70.  
  71.         // Проверяем, не добавлены ли уже кнопки
  72.         if (targetElement.parentNode.querySelector('.film-search-btns')) return;
  73.  
  74.         // Контейнер для кнопок
  75.         const container = document.createElement("div");
  76.         container.className = "film-search-btns";
  77.         container.style.cssText = `
  78.             display: flex;
  79.             gap: 8px;
  80.             margin: 12px 0 12px 16px;
  81.             flex-wrap: wrap;
  82.         `;
  83.  
  84.         // Кнопка ВК
  85.         const btnVK = document.createElement("button");
  86.         btnVK.innerText = "🔍 Найти в ВК";
  87.         btnVK.style.cssText = `
  88.             padding: 10px 16px;
  89.             background: #4C75A3;
  90.             color: white;
  91.             border: none;
  92.             border-radius: 8px;
  93.             cursor: pointer;
  94.             font-size: 14px;
  95.             font-weight: bold;
  96.             box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  97.             transition: all 0.2s ease;
  98.         `;
  99.         btnVK.onmouseover = () => {
  100.             btnVK.style.background = "#3a5a7f";
  101.             btnVK.style.transform = "translateY(-1px)";
  102.             btnVK.style.boxShadow = "0 4px 8px rgba(0,0,0,0.3)";
  103.         };
  104.         btnVK.onmouseout = () => {
  105.             btnVK.style.background = "#4C75A3";
  106.             btnVK.style.transform = "translateY(0)";
  107.             btnVK.style.boxShadow = "0 2px 5px rgba(0,0,0,0.2)";
  108.         };
  109.         btnVK.addEventListener("click", (e) => {
  110.             e.preventDefault();
  111.             const vkUrl = `https://vk.com/search/video?q=${encodeURIComponent(title)}`;
  112.             window.open(vkUrl, "_blank", "noopener,noreferrer");
  113.         });
  114.  
  115.         // Кнопка RuTube
  116.         const btnRuTube = document.createElement("button");
  117.         btnRuTube.innerText = "🎥 Найти в RuTube";
  118.         btnRuTube.style.cssText = `
  119.             padding: 10px 16px;
  120.             background: #E63946;
  121.             color: white;
  122.             border: none;
  123.             border-radius: 8px;
  124.             cursor: pointer;
  125.             font-size: 14px;
  126.             font-weight: bold;
  127.             box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  128.             transition: all 0.2s ease;
  129.         `;
  130.         btnRuTube.onmouseover = () => {
  131.             btnRuTube.style.background = "#c1121f";
  132.             btnRuTube.style.transform = "translateY(-1px)";
  133.             btnRuTube.style.boxShadow = "0 4px 8px rgba(0,0,0,0.3)";
  134.         };
  135.         btnRuTube.onmouseout = () => {
  136.             btnRuTube.style.background = "#E63946";
  137.             btnRuTube.style.transform = "translateY(0)";
  138.             btnRuTube.style.boxShadow = "0 2px 5px rgba(0,0,0,0.2)";
  139.         };
  140.         btnRuTube.addEventListener("click", (e) => {
  141.             e.preventDefault();
  142.             const rutubeUrl = `https://rutube.ru/search/?query=${encodeURIComponent(title)}`;
  143.             window.open(rutubeUrl, "_blank", "noopener,noreferrer");
  144.         });
  145.  
  146.         // Кнопка flcksbr (только если есть filmId и это Кинопоиска)
  147.         // Исправлено: работает и для /series/, и для /film/
  148.         if (filmId && window.location.hostname.includes("kinopoisk.ru")) {
  149.             const btnFlcksbr = document.createElement("button");
  150.             btnFlcksbr.innerText = "📺 Открыть в flcksbr";
  151.             btnFlcksbr.style.cssText = `
  152.                 padding: 10px 16px;
  153.                 background: #5A4FCF;
  154.                 color: white;
  155.                 border: none;
  156.                 border-radius: 8px;
  157.                 cursor: pointer;
  158.                 font-size: 14px;
  159.                 font-weight: bold;
  160.                 box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  161.                 transition: all 0.2s ease;
  162.             `;
  163.             btnFlcksbr.onmouseover = () => {
  164.                 btnFlcksbr.style.background = "#453bb0";
  165.                 btnFlcksbr.style.transform = "translateY(-1px)";
  166.                 btnFlcksbr.style.boxShadow = "0 4px 8px rgba(0,0,0,0.3)";
  167.             };
  168.             btnFlcksbr.onmouseout = () => {
  169.                 btnFlcksbr.style.background = "#5A4FCF";
  170.                 btnFlcksbr.style.transform = "translateY(0)";
  171.                 btnFlcksbr.style.boxShadow = "0 2px 5px rgba(0,0,0,0.2)";
  172.             };
  173.             btnFlcksbr.addEventListener("click", (e) => {
  174.                 e.preventDefault();
  175.                 const flcksbrUrl = `https://www.sspoisk.ru/film/${filmId}/`;
  176.                 window.open(flcksbrUrl, "_blank", "noopener,noreferrer");
  177.             });
  178.  
  179.             container.appendChild(btnFlcksbr);
  180.         }
  181.  
  182.         // Добавляем кнопки в контейнер
  183.         container.appendChild(btnVK);
  184.         container.appendChild(btnRuTube);
  185.  
  186.         // Вставляем рядом с заголовком
  187.         targetElement.parentNode.insertBefore(container, targetElement.nextSibling);
  188.     }
  189.  
  190.     // Функция для запуска addButton с защитой от повторных вызовов
  191.     let isAdding = false; // Флаг, чтобы не запускать addButton параллельно
  192.     function safeAddButton() {
  193.         if (isAdding) return;
  194.         isAdding = true;
  195.         try {
  196.             addButton();
  197.         } finally {
  198.             isAdding = false;
  199.         }
  200.     }
  201.  
  202.     // Запускаем сразу, на случай, если элемент уже есть
  203.     if (document.readyState === "loading") {
  204.         document.addEventListener("DOMContentLoaded", safeAddButton);
  205.     } else {
  206.         safeAddButton();
  207.     }
  208.  
  209.     // Создаем MutationObserver, который будет следить за появлением целевых элементов
  210.     const selectorsToWatch = getSelectors().join(', ');
  211.     const observer = new MutationObserver((mutations, obs) => {
  212.         // Проверяем, появился ли хотя бы один из нужных элементов
  213.         if (document.querySelector(selectorsToWatch)) {
  214.             safeAddButton();
  215.         }
  216.     });
  217.  
  218.     // Начинаем наблюдение за изменениями в DOM
  219.     observer.observe(document.body, { childList: true, subtree: true });
  220.  
  221. })();
Advertisement
Add Comment
Please, Sign In to add comment