// ==UserScript==
// @name Кнопка перехода на Flicksbar из Kinorium (без использования API Кинопоиска)
// @namespace http://tampermonkey.net/
// @version 1.0.5.1.0
// @description Ищет фильм в Google и автоматически переходит на Flicksbar без использования API Кинопоиска
// @author CgPT & Vladimir_0202
// @icon https://ru.kinorium.com/favicon.ico
// @match *://*.kinorium.com/*
// @match *://www.google.com/search*
// @match *://flicksbar.mom/*
// @grant GM_setValue
// @grant GM_getValue
// @license MIT
// @downloadURL none
// ==/UserScript==
(function () {
'use strict';
const url = window.location.href;
// === 1. KINORIUM: Добавляем кнопку на страницу фильма ===
if (/kinorium\.com\/\d+\/?$/.test(url)) {
// Сохраняем постер и описание в хранилище Tampermonkey
const posterEl = document.querySelector('.jsCarouselImageContainer img');
const descEl = document.querySelector('.film-page__text');
const titleEl = document.querySelector('.film-page__title-text.film-page__itemprop');
const originalTitleEl = document.querySelector('.film-page__orig_with_comment');
const yearEl = document.querySelector('.film-page__date a[href*="years_min="]');
const raitingEl = document.querySelector('.film-page__title-rating');
const poster = posterEl?.src;
const description = descEl?.innerText;
const titleTMP = titleEl?.innerText;
const originalTitleTMP = originalTitleEl?.innerText;
const yearTMP = yearEl?.innerText;
const raitingTMP = raitingEl?.innerText;
if (poster && description) {
GM_setValue('flicksbar_poster', poster); // Сохраняем в хранилище Tampermonkey
GM_setValue('flicksbar_description', description); // Сохраняем в хранилище Tampermonkey
GM_setValue('flicksbar_titleTMP', titleTMP); // Сохраняем в хранилище Tampermonkey
GM_setValue('flicksbar_originalTitleTMP', originalTitleTMP); // Сохраняем в хранилище Tampermonkey
GM_setValue('flicksbar_yearTMP', yearTMP); // Сохраняем в хранилище Tampermonkey
GM_setValue('flicksbar_raitingTMP', raitingTMP); // Сохраняем в хранилище Tampermonkey
console.log('✅ Постер и описание сохранены в Tampermonkey storage');
} else {
console.warn('⚠️ Не удалось найти постер или описание');
}
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 yearElement = document.querySelector('.film-page__date a[href*="years_min="]');
const title = titleElement ? titleElement.textContent.trim() : '';
const originalTitle = originalTitleElement ? originalTitleElement.textContent.trim() : '';
const year = yearElement ? yearElement.textContent.trim() : '';
const isSeries = typeLink !== null;
return { title, originalTitle, year, isSeries };
}
function createButton() {
const button = document.createElement('button');
button.innerHTML = '▶Смотреть на Flicksbar';
button.style.cssText = `
padding: 9px;
margin-top: -5px;
margin-bottom: 2px;
background-color: #007bff;
color: white;
border: none;
border-radius: 3px;
width: 100%;
cursor: pointer;
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}" бесплатно онлайн на Flicksbar`;
button.onclick = () => {
const { title, originalTitle, year, isSeries } = getFilmDetails();
if (!title) return alert('Не удалось извлечь информацию о фильме.');
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('Элемент для вставки кнопки не найден.');
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', createButton);
} else {
createButton();
}
}
// === 2. GOOGLE: Автопереход на Flicksbar по найденному ID Кинопоиска ===
if (/google\.com\/search/.test(url)) {
function showConfirmWithTimeout(flicksbarUrl, timeout = 5000) {
return new Promise((resolve) => {
const modal = document.createElement('div');
Object.assign(modal.style, {
position: 'fixed',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
padding: '20px',
backgroundColor: '#EEE8AA',
border: '1px solid #ccc',
zIndex: '9999',
boxShadow: '0 4px 8px rgba(0, 0, 0, 0.2)',
borderRadius: '8px',
});
const message = document.createElement('p');
message.style.color = 'black';
message.innerHTML = `Переход на Flicksbar
Перейти по ссылке: ${flicksbarUrl} ?`;
modal.appendChild(message);
const okButton = document.createElement('button');
okButton.textContent = 'Да';
Object.assign(okButton.style, {
marginRight: '10px',
padding: '5px 10px',
backgroundColor: '#28a745',
color: 'white',
border: 'none',
cursor: 'pointer',
borderRadius: '5px',
});
okButton.onclick = () => {
resolve(true);
modal.remove();
};
modal.appendChild(okButton);
const cancelButton = document.createElement('button');
cancelButton.textContent = 'Нет';
Object.assign(cancelButton.style, {
padding: '5px 10px',
backgroundColor: '#dc3545',
color: 'white',
border: 'none',
cursor: 'pointer',
borderRadius: '5px',
});
cancelButton.onclick = () => {
resolve(false);
modal.remove();
};
modal.appendChild(cancelButton);
document.body.appendChild(modal);
setTimeout(() => {
resolve(false); //resolve(false); - если надо чтобы после таймера нажималась кнопка Отмена
modal.remove();
}, timeout);
});
}
async function tryRedirect() {
const kpLink = document.querySelector('a[href*="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 = await showConfirmWithTimeout(flicksbarUrl, 5000); //чтобы производился Автопереход без окна запроса, то закоментирвать это!
if (answer) window.location.href = flicksbarUrl; //и это закоментирвать
else console.log('Переход отменен пользователем или истек таймаут.'); //и вот это закоментирвать
//window.location.href = flicksbarUrl; // А это раскомментировать!
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', tryRedirect);
} else {
tryRedirect();
}
}
// === 3. Flicksbar: изменение плеера и добавление постера и описания ===
if (/flicksbar\.mom\/film\/\d+\/?$/.test(location.href)) {
// Функция для отображения постера и описания в блоке справа
function displayMovieInfo(poster, description, titleTMP, originalTitleTMP, yearTMP, raitingTMP) {
const infoBox = document.getElementById("kinorium-info");
if (infoBox && poster && description && titleTMP && originalTitleTMP && yearTMP && raitingTMP) {
infoBox.innerHTML = `
${titleTMP} ${originalTitleTMP} ${yearTMP} ${raitingTMP}
${description}
`; } } // Убираем рекламу function removeAds() { const selectors = [ "#tgWrapper", "#TopAdMb", ".brand", ".topAdPad", ".adDown", "body > span", "body > script:first-child" ]; selectors.forEach(sel => { const el = document.querySelector(sel); if (el) el.remove(); }); } // Структурируем страницу function restructurePage() { const main = document.querySelector(".mainContainer"); const player = document.querySelector(".kinobox"); if (!main || !player) return; player.style.minHeight = "0"; player.style.height = "100%"; const layout = document.createElement("div"); layout.style.display = "flex"; layout.style.gap = "30px"; layout.style.marginTop = "20px"; layout.style.alignItems = "stretch"; const left = document.createElement("div"); left.style.flex = "7"; left.style.height = "80%"; left.style.minHeight = "500px"; left.style.marginLeft = "5px"; left.style.display = "flex"; left.style.flexDirection = "column"; left.appendChild(player); const right = document.createElement("div"); right.style.flex = "3"; right.style.fontFamily = "sans-serif"; right.style.color = "#eee"; right.style.borderRadius = "5px"; right.style.marginRight = "5px"; right.style.padding = "15px"; right.style.background = "#222"; right.style.overflow = "hidden"; // ограничим всё внутри const infoWrapper = document.createElement("div"); infoWrapper.id = "kinorium-info"; //infoWrapper.style.display = "flex"; infoWrapper.style.flexDirection = "column"; infoWrapper.style.gap = "20px"; infoWrapper.style.maxHeight = "100%"; right.appendChild(infoWrapper); layout.appendChild(left); layout.appendChild(right); main.innerHTML = ""; main.appendChild(layout); } // Добавялем инфу про фильм function loadAndDisplayInfo() { const poster = GM_getValue('flicksbar_poster', null); const description = GM_getValue('flicksbar_description', null); const titleTMP = GM_getValue('flicksbar_titleTMP', null); const originalTitleTMP = GM_getValue('flicksbar_originalTitleTMP', null); const yearTMP = GM_getValue('flicksbar_yearTMP', null); const raitingTMP = GM_getValue('flicksbar_raitingTMP', null); const infoContainer = document.querySelector("#kinorium-info"); if (!infoContainer) { console.log('#kinorium-info element not found on the page.'); return; } infoContainer.innerHTML = ""; // Заголовок if (titleTMP || originalTitleTMP || yearTMP) { const titleElement = document.createElement("div"); titleElement.innerHTML = `