Автопереход на Flicksbar с Google

Находит ссылку на Кинопоиск и переходит на Flicksbar

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

// ==UserScript==
// @name         Автопереход на Flicksbar с Google
// @namespace    http://tampermonkey.net/
// @version      0.1.2
// @icon         https://icons.iconarchive.com/icons/designbolts/free-multimedia/256/Film-icon.png
// @description  Находит ссылку на Кинопоиск и переходит на Flicksbar
// @match        https://www.google.com/search*
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    function showConfirmWithTimeout(flicksbarUrl, timeout = 5000) {
        return new Promise((resolve) => {
            const modal = document.createElement('div');
            modal.style.position = 'fixed';
            modal.style.top = '50%';
            modal.style.left = '50%';
            modal.style.transform = 'translate(-50%, -50%)';
            modal.style.padding = '20px';
            modal.style.backgroundColor = '#EEE8AA'; // светло-оранжевый цвет фона
            modal.style.border = '1px solid #ccc';
            modal.style.zIndex = '9999';
            modal.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.2)';
            modal.style.borderRadius = '8px'; // Закругленные углы для красоты

            const message = document.createElement('p');
            message.textContent = `Перейти по ссылке: ${flicksbarUrl}?`;
            modal.appendChild(message);

            const okButton = document.createElement('button');
            okButton.textContent = 'Да';
            okButton.style.marginRight = '10px'; // Немного отступа
            okButton.style.padding = '5px 10px';
            okButton.style.backgroundColor = '#28a745'; // Зеленая кнопка "ОК"
            okButton.style.color = 'white';
            okButton.style.border = 'none';
            okButton.style.borderRadius = '5px';
            okButton.onclick = () => {
                resolve(true);
                document.body.removeChild(modal);
            };
            modal.appendChild(okButton);

            const cancelButton = document.createElement('button');
            cancelButton.textContent = 'Нет';
            cancelButton.style.padding = '5px 10px';
            cancelButton.style.backgroundColor = '#dc3545'; // Красная кнопка "Отмена"
            cancelButton.style.color = 'white';
            cancelButton.style.border = 'none';
            cancelButton.style.borderRadius = '5px';
            cancelButton.onclick = () => {
                resolve(false);
                document.body.removeChild(modal);
            };
            modal.appendChild(cancelButton);

            document.body.appendChild(modal);

            // Таймаут, если пользователь не нажал кнопку в течение заданного времени
            setTimeout(() => {
                resolve(false);
                document.body.removeChild(modal); // Закрыть окно по таймауту
            }, timeout);
        });
    }

    async function handleRedirect(flicksbarUrl) {
        const answer = await showConfirmWithTimeout(flicksbarUrl, 5000); // Таймаут 5 секунд
        if (answer) {
            window.location.href = flicksbarUrl;
        } else {
            console.log('Пользователь не подтвердил переход.');
        }
    }


    // Ждем пока DOM подгрузится
    window.addEventListener('load', () => {
        const links = [...document.querySelectorAll('a')];
        const kpLink = links.find(a => a.href.includes('kinopoisk.ru/film/'));

        if (!kpLink) return;

        const match = kpLink.href.match(/kinopoisk\.ru\/film\/(\d+)/);
        if (!match) return;

        const kpId = match[1];

        const urlParams = new URLSearchParams(window.location.search);
        const type = urlParams.get('flcks_type') || 'film';

        const flicksbarUrl = `https://flicksbar.mom/${type}/${kpId}/`;
        //const answer = confirm(`Перейти по ссылке: ${flicksbarUrl}?`);
        //window.location.href = flicksbarUrl;
        handleRedirect(flicksbarUrl);
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址