DVDs ReleaseDates helper

Add external links

目前為 2018-08-12 提交的版本,檢視 最新版本

// ==UserScript==
// @name        DVDs ReleaseDates helper
// @namespace   V@no
// @description Add external links
// @include     http://www.dvdsreleasedates.com/*
// @include     https://www.dvdsreleasedates.com/*
// @version     1.2.5
// @grant       none
// ==/UserScript==

function $(id)
{
	return document.getElementById(id);
}

function urlencode(url)
{
	return encodeURI(url).replace(/%5B/g, '[').replace(/%5D/g, ']');
}

let links = [
		{
			name: "ThePirateBay",
			nameShort: "TPB",
			url: "https://thepiratebay.org/search/{S}/0/3/0",
			icon: ""
		},
		{
			name: "1337x",
			nameShort: "1337x",
			url: "https://x1337x.eu/sort-category-search/{S}/Movies/time/desc/1/",
			icon: ""
		},
		{
			name: "RARBG",
			nameShort: "RARBG",
			url: "https://rarbg.to/torrents.php?search={S}&order=data&by=DESC",
			icon: ""
		},
/*
		{
			name: "OMDB",
			nameShort: "OMDB",
			url: "http://www.omdbapi.com/?t={S}",
			icon: "",
			
		}
*/

];

function cleanup(t)
{
	t = t.replace(/[-:,]\s(season\s(\w+))$/i, season);
	t = t.replace(/\[[^\]]*\]/g, "");
	let l = ["4k", "ultra", "hd", "bd", "ultrahd", "edition"];
	for(let i = 0; i < l.length; i++)
	{
		t = t.replace(new RegExp("\\b" + l[i] + "\\b", "gi"), "");
	}
	return t;
}

function season(a, b, c, d)
{
	let n = ["", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"],
			i = n.indexOf(c.toLowerCase());

	if (i == -1)
		i = c.replace(/[a-zA-Z]+/g, "");

	return " S" + i;
}

let td = document.getElementsByClassName("dvdcell");
for(let i = 0; i < td.length; i++)
{
	let title = "",
			a = td[i].getElementsByTagName("a");

	for(let t = 0; t < a.length; t++)
	{
		if (!a[t].children.length)
		{
			title = a[t].textContent;
			break;
		}
	}
	if (!title)
		continue;

	let div = document.createElement("div");

	div.className = "links";
	for(let n = 0; n < links.length; n++)
	{
		let a = document.createElement("a"),
				img = document.createElement("img"),
				item = links[n],
				dom = item.url.match(/\/\/([^\/{}]+)/)[1],
				icoUrl = item.icon || "http://www.google.com/s2/favicons?domain=" + dom;

		a.href = item.url.replace("{S}", urlencode(cleanup(title)));
		a.setAttribute("target", "_blank");
		img.src = icoUrl;
		img.title = item.name;
		a.appendChild(img);
		div.appendChild(a);
	}
	td[i].appendChild(div);
}


//create stylesheet. A little trick to have multiline text
var	style = document.createElement("style"),
		css = function(){/*
div.links
{
	display: block;
	text-align: center;
}
div.links > a
{
	padding-right: 2px;
	padding-left: 2px;
	border-right: 1px dotted silver;

}
div.links > a:last-child
{
	padding-right: 2px;
	border-right: 0;
}

*/};
style.innerHTML = css.toString().slice(14, -3).replace(/\*\/\/\*/g, "*/");
document.getElementsByTagName("head")[0].appendChild(style);

QingJ © 2025

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