Guest User

Найти фильм в ВК или RuTube

a guest
Sep 7th, 2025
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Найти фильм в ВК или RuTube — ФИНАЛЬНАЯ ВЕРСИЯ 2025
  3. // @namespace    http://tampermonkey.net/
  4. // @version      1.5
  5. // @description  Добавляет кнопки поиска фильма в ВК и RuTube. Использует актуальные селекторы и прямые URL.
  6. // @author       @shittykitty_
  7. // @match        *://www.kinopoisk.ru/film/*
  8. // @match        *://www.imdb.com/title/*
  9. // @grant        none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13.     'use strict';
  14.  
  15.     function addButton() {
  16.         let title = "";
  17.         let targetElement = null;
  18.  
  19.         // Для Кинопоиска
  20.         if (window.location.hostname.includes("kinopoisk.ru")) {
  21.             const selectors = [
  22.                 'span[data-tid="75209b22"]', // АКТУАЛЬНЫЙ 2025
  23.                 '.film-header__title',
  24.                 '.film-page__title',
  25.                 'h1[itemprop="name"]',
  26.                 'h1',
  27.                 'span[itemprop="name"]'
  28.             ];
  29.             for (let sel of selectors) {
  30.                 const el = document.querySelector(sel);
  31.                 if (el && el.innerText.trim().length > 0) {
  32.                     title = el.innerText.trim();
  33.                     targetElement = el;
  34.                     break;
  35.                 }
  36.             }
  37.         }
  38.  
  39.         // Для IMDb
  40.         if (window.location.hostname.includes("imdb.com")) {
  41.             const selectors = [
  42.                 'h1[data-testid="hero__pageTitle"]',
  43.                 '.hero__primary-text',
  44.                 'h1[itemprop="name"]',
  45.                 'h1'
  46.             ];
  47.             for (let sel of selectors) {
  48.                 const el = document.querySelector(sel);
  49.                 if (el && el.innerText.trim().length > 0) {
  50.                     title = el.innerText.trim();
  51.                     targetElement = el;
  52.                     break;
  53.                 }
  54.             }
  55.         }
  56.  
  57.         if (!title || !targetElement) return;
  58.  
  59.         // Проверяем, не добавлены ли уже кнопки
  60.         if (targetElement.parentNode.querySelector('.film-search-btns')) return;
  61.  
  62.         // Контейнер для кнопок
  63.         const container = document.createElement("div");
  64.         container.className = "film-search-btns";
  65.         container.style.cssText = `
  66.             display: flex;
  67.             gap: 8px;
  68.             margin: 12px 0 12px 16px;
  69.             flex-wrap: wrap;
  70.         `;
  71.  
  72.         // Кнопка ВК
  73.         const btnVK = document.createElement("button");
  74.         btnVK.innerText = "🔍 Найти в ВК";
  75.         btnVK.style.cssText = `
  76.             padding: 10px 16px;
  77.             background: #4C75A3;
  78.             color: white;
  79.             border: none;
  80.             border-radius: 8px;
  81.             cursor: pointer;
  82.             font-size: 14px;
  83.             font-weight: bold;
  84.             box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  85.             transition: all 0.2s ease;
  86.         `;
  87.         btnVK.onmouseover = () => {
  88.             btnVK.style.background = "#3a5a7f";
  89.             btnVK.style.transform = "translateY(-1px)";
  90.             btnVK.style.boxShadow = "0 4px 8px rgba(0,0,0,0.3)";
  91.         };
  92.         btnVK.onmouseout = () => {
  93.             btnVK.style.background = "#4C75A3";
  94.             btnVK.style.transform = "translateY(0)";
  95.             btnVK.style.boxShadow = "0 2px 5px rgba(0,0,0,0.2)";
  96.         };
  97.         btnVK.addEventListener("click", (e) => {
  98.             e.preventDefault();
  99.             const vkUrl = `https://vk.com/search/video?q=${encodeURIComponent(title)}`;
  100.             window.open(vkUrl, "_blank", "noopener,noreferrer");
  101.         });
  102.  
  103.         // Кнопка RuTube
  104.         const btnRuTube = document.createElement("button");
  105.         btnRuTube.innerText = "🎥 Найти в RuTube";
  106.         btnRuTube.style.cssText = `
  107.             padding: 10px 16px;
  108.             background: #E63946;
  109.             color: white;
  110.             border: none;
  111.             border-radius: 8px;
  112.             cursor: pointer;
  113.             font-size: 14px;
  114.             font-weight: bold;
  115.             box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  116.             transition: all 0.2s ease;
  117.         `;
  118.         btnRuTube.onmouseover = () => {
  119.             btnRuTube.style.background = "#c1121f";
  120.             btnRuTube.style.transform = "translateY(-1px)";
  121.             btnRuTube.style.boxShadow = "0 4px 8px rgba(0,0,0,0.3)";
  122.         };
  123.         btnRuTube.onmouseout = () => {
  124.             btnRuTube.style.background = "#E63946";
  125.             btnRuTube.style.transform = "translateY(0)";
  126.             btnRuTube.style.boxShadow = "0 2px 5px rgba(0,0,0,0.2)";
  127.         };
  128.         btnRuTube.addEventListener("click", (e) => {
  129.             e.preventDefault();
  130.             const rutubeUrl = `https://rutube.ru/search/?query=${encodeURIComponent(title)}`;
  131.             window.open(rutubeUrl, "_blank", "noopener,noreferrer");
  132.         });
  133.  
  134.         // Добавляем кнопки в контейнер
  135.         container.appendChild(btnVK);
  136.         container.appendChild(btnRuTube);
  137.  
  138.         // Вставляем рядом с заголовком
  139.         targetElement.parentNode.insertBefore(container, targetElement.nextSibling);
  140.     }
  141.  
  142.     // Запускаем после загрузки
  143.     if (document.readyState === "loading") {
  144.         document.addEventListener("DOMContentLoaded", addButton);
  145.     } else {
  146.         addButton();
  147.     }
  148.  
  149.     // Наблюдаем за изменениями DOM — для SPA
  150.     const observer = new MutationObserver(() => {
  151.         addButton();
  152.     });
  153.     observer.observe(document.body, { childList: true, subtree: true });
  154. })();
Advertisement
Add Comment
Please, Sign In to add comment