Greasy Fork

Greasy Fork is available in English.

Кнопка перехода на Flicksbar из Kinorium (без использования API Кинопоиска)

Ищет фильм в Google и автоматически переходит на Flicksbar без использования API Кинопоиска (для правильной работы нужен второй скрипт "Автопереход на Flicksbar с Google")

当前为 2025-04-09 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Кнопка перехода на Flicksbar из Kinorium (без использования API Кинопоиска)
// @namespace    http://tampermonkey.net/
// @version      0.9.5
// @description  Ищет фильм в Google и автоматически переходит на Flicksbar без использования API Кинопоиска (для правильной работы нужен второй скрипт "Автопереход на Flicksbar с Google")
// @author       CgPT & Vladimir_0202
// @icon         https://ru.kinorium.com/favicon.ico
// @include      /^https?:\/\/.*kinorium.*\/.*$/
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    // Проверка: находимся ли мы на главной странице фильма (например: https://kinorium.com/247921/)
    const path = window.location.pathname;
    const isMainFilmPage = /^\/\d+\/?$/.test(path);

    if (!isMainFilmPage) {
        console.log('Не главная страница фильма, кнопка не будет добавлена.');
        return;
    }

    function getFilmDetails() {
        const titleElement = document.querySelector('.film-page__title-text.film-page__itemprop');
        const originalTitleElement = document.querySelector('.film-page__orig_with_comment');
        const typeLink = document.querySelector('.b-post__info a[href*="/series/"]');

        const title = titleElement ? titleElement.textContent.trim() : '';
        const originalTitle = originalTitleElement ? originalTitleElement.textContent.trim() : '';
        const yearElement = document.querySelector('.film-page__date a[href*="years_min="]');
        const year = yearElement ? yearElement.textContent.trim() : '';

        console.log(`Extracted movie data: Title: "${title}", Original Title: "${originalTitle}", Year: "${year}"`);

        const isSeries = typeLink !== null;
        return { title, originalTitle, year, isSeries };
    }

    function createButton() {
        const button = document.createElement('button');
        button.textContent = 'Смотреть на Flicksbar';
        button.style.padding = '9px';
        button.style.marginTop = '5px';
        button.style.marginBottom = '2px';
        button.style.backgroundColor = '#007bff';
        button.style.color = 'white';
        button.style.border = 'none';
        button.style.borderRadius = '3px';
        button.style.width = '100%';
        button.style.cursor = 'pointer';
        button.style.transition = 'background-color 0.3s ease';

        // Наведение: делаем цвет темнее
        button.addEventListener('mouseenter', () => {
            button.style.backgroundColor = '#0056b3'; // темно-синий
        });

        button.addEventListener('mouseleave', () => {
            button.style.backgroundColor = '#007bff'; // обратно как было
        });

        const { title, originalTitle, year } = getFilmDetails();
        button.title = `Поиск: ${title} ${originalTitle} ${year}`;

        button.onclick = () => {
            const { title, originalTitle, year, isSeries } = getFilmDetails();
            if (!title) {
                alert('Не удалось извлечь информацию о фильме.');
                return;
            }

            const searchQuery = encodeURIComponent(`${title} ${originalTitle} ${year} кинопоиск`);
            const flicksbarType = isSeries ? 'series' : 'film';
            const googleUrl = `https://www.google.com/search?q=${searchQuery}&btnK&flcks_type=${flicksbarType}`;

            window.open(googleUrl, '_blank');
        };

        const sideCover = document.querySelector('.collectionWidget.collectionWidgetData.withFavourites');
        if (sideCover) {
            sideCover.appendChild(button);
        } else {
            console.warn('Элемент для вставки кнопки не найден.');
        }
    }

    // Запуск как можно раньше, но только после готовности DOM
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', createButton);
    } else {
        createButton();
    }
})();