Greasy Fork

KickassTorrents + Yt + IMDb

add youtube popup and imdb rating to main movies page, this fixes the five fingers

目前为 2014-12-23 提交的版本。查看 最新版本

// ==UserScript==
// @version     1.0.0      
// @name    KickassTorrents + Yt + IMDb
// @description     add youtube popup and imdb rating to main movies page, this fixes the five fingers
// @namespace     https://greasyfork.org/users/3159  
// @include     http://kickass.so/movies/*
// @include     https://kickass.so/movies/*
// ==/UserScript==
//minus IMDb for now
var box = document.getElementsByClassName('iaconbox');
var nlink = document.getElementsByClassName('cellMainLink');
var names = [];

function fixTitle(title) {
	title = title.replace(/[()]/g, '').replace(/[.]/g, ' '); // remove unwanted characters
	title = title.replace(/([1|2][8|9|0][0-9]{2}).*/, '$1'); // trim after date
	return title;
}

for (i = 0; i < box.length; i++) {
	box[i].children[4] ? box[i].children[4].style.display = "none" : null;
	box[i].children[2] ? box[i].children[2].style.display = "none" : null;
	box[i].children[3] ? box[i].children[3].children[0].className += " partner1Button" : null;
	names.push(fixTitle(nlink[i].innerText));
}

bg = document.createElement("div");
bg.style.cssText = "background:rgba(0, 0, 0,.8);position:fixed;top:0;z-index:9999;width:100%;height:100%;display:none";
bg.onclick = function () {
	bg.style.display = "none";
	bg.innerHTML = "";
};
document.body.appendChild(bg);

for (var i = 0; i < box.length; i++) {
	box[i].insertAdjacentHTML("beforeend", "<a title=YouTube class='icon16 yt' style='background: linear-gradient(to bottom, #c85229 0%, #c62c00 100%)'><em style='font-size: 12px;margin:5px 6px 0 0' class='iconvalue'>Yt</em></a>");
	var x = encodeURIComponent(names[i]).replace(/%20/g, '+').replace(/'/g, '%27'); // replace space with plus and apostrophe with %27
	eval("document.getElementsByClassName('yt')[i].onclick = function (){bg.style.display='block';bg.innerHTML='<iframe style=border:0;width:640px;height:390px;max-width:90%;max-height:90%;margin:auto;position:absolute;top:0;left:0;bottom:0;right:0; src=//youtube.com/embed/?listType=search&list=" + x + "&autohide=1&autoplay=1></iframe>'};"); //autoplay isn't supported
}