NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name SCintegracia
// @license MIT
// @namespace https://stream-cinema.online/
// @downloadURL https://stream-cinema.online/widget/csfd.js
// @updateURL https://openuserjs.org/meta/bbaronSVK/SCintegracia.meta.js
// @version 1.3
// @description Integracia SC do csfd, imdb a trakt
// @author Me
// @match https://www.csfd.cz/film/*
// @match https://www.csfd.cz/zebricky/*
// @match https://www.csfd.cz/podrobne-vyhledavani/*
// @match https://www.csfd.cz/hledat/*
// @match https://www.csfd.sk/film/*
// @match https://www.csfd.sk/zebricky/*
// @match https://www.csfd.sk/podrobne-vyhladavanie/*
// @match https://www.csfd.sk/hladat/*
// @match https://www.imdb.com/title/*
// @match https://trakt.tv/*
// @grant none
// ==/UserScript==
/* jshint esversion: 6 */
/* globals $, jQuery */
'use strict';
var vurl = null;
var pushState = history.pushState;
var timeout = null;
var level = 0;
history.pushState = function () {
pushState.apply(history, arguments);
console.log('zmena URL');
level = 0;
scIntegrate();
};
function cmajzniZoznam(zlodej) {
let zoznam = [];
$(zlodej + ' a').each((e, a) => {
let match = $(a).attr('href').match(/film\/([0-9]+)\-/);
if (match[1] > 0) {
$(a).attr('data-sc', match[1]);
zoznam.push(match[1]);
}
});
return zoznam;
}
function scIntegrate() {
const href = window.location.href;
console.log('[SC] integracia %o', href);
if (href.indexOf('trakt.tv') > 0) {
if (href.indexOf('movie') || href.indexOf('shows')) {
var data = $('.summary-user-rating').data();
console.log('data: %o', data);
if (data && (data.type == 'show' || data.type == 'episode')) {
vurl = 'https://stream-cinema.online/widget/csfd?t=3;g=' + encodeURIComponent(data.showId);
}
else if (data) {
vurl = 'https://stream-cinema.online/widget/csfd?t=1;g=' + encodeURIComponent(data.movieId);
}
else {
console.log('[SC] nemam data');
if (timeout) {
clearTimeout(timeout);
}
if (level < 10) {
timeout = setTimeout(scIntegrate, 250);
level++;
}
return;
}
console.log(vurl);
}
} else if (href.match(/csfd.(cz|sk)/) != -1 && (href.match(/[zr]ebricky|\/podrobne\-vyhl[ea]davanie?|hl[ea]dat/) !== null)) {
let zoznam = [];
zoznam = cmajzniZoznam('td.title');
if (zoznam.length == 0) {
zoznam = cmajzniZoznam('article.article-poster-60 header');
}
console.log('[SC] zoznam: %o', zoznam);
$.ajax('//stream-cinema.online/widget/ajax?g=list', {
data: {list: zoznam},
type: 'POST',
success: (r) => {
r.forEach(e => {
const html = '<a href="https://stream-cinema.online/film/csfd/'+e+'"><img src="https://stream-cinema.online/Nof7AYf1.png" width="15px" style="margin-right: 5px;"></a>';
$('*[data-sc="' + e + '"]').prepend(html);
})
}
});
return;
} else {
vurl = 'https://stream-cinema.online/widget/csfd?g=' + encodeURIComponent(window.location);
}
var bbga = document.createElement('script');
bbga.type = 'text/javascript';
bbga.async = true;
bbga.src = vurl;
var bbs = document.getElementsByTagName('script')[0];
bbs.parentNode.insertBefore(bbga, bbs);
}
scIntegrate();