// ==UserScript==
// @id [email protected]
// @name 豆瓣电影C+|MyDoubanMovieHelper|豆瓣|豆瓣电影|douban.movie.com
// @namespace douban.com
// @version 0.3.1
// @description 在 movie.douban.com 网站下直接显示下载链接,可通过多个站点获取。
// @author c wt U r
// @match https://movie.douban.com/subject/*
// @connect mp4ba.com
// @connect edmag.net
// @connect tl95.com
// @connect kat.cr
// @require http://code.jquery.com/jquery-1.9.1.min.js
// @require https://cdn.bootcss.com/jBox/0.3.2/jBox.min.js
// @grant GM_xmlhttpRequest
// ==/UserScript==
/**
* Created by c wt U r on 2016/5/18.
* QQ 3099891314
*
* node{detailURL,downloadURL,date,type[0,1,2],title}
* type[0 , // mag
* 1 , // ed2k
* 2 , // thunder
* 3 // netdisk
* ]
*/
addCSSfile("https://cdn.bootcss.com/jBox/0.3.2/jBox.min.css");
function addCSSfile(a) {
$("<link>").attr({
rel: "stylesheet",
type: "text/css",
href: a
}).appendTo("head")
}
function getDoc(a, b, c) {
GM_xmlhttpRequest({
method: c ? "POST" : "GET",
url: a,
headers: {
"User-agent": window.navigator.userAgent,
"Content-type": c ? "application/x-www-form-urlencoded" : null
},
onload: function(c) {
var g = "";
200 == c.status && (g = (new DOMParser).parseFromString(c.responseText, "text/html"), void 0 === g && (g = document.implementation.createHTMLDocument(""), g.querySelector("html").innerHTML = responseText));
b(g, a)
}
})
}
function timeago(a) {
a = new Date(a);
var b, c, d;
b = parseInt((new Date).getTime() / 1E3) - a;
d = parseInt(b / 86400);
c = parseInt(b / 3600);
b = parseInt(b / 60);
if (0 < d && 4 > d) return d + "\u5929\u524d";
if (0 >= d && 0 < c) return c + "\u5c0f\u65f6\u524d";
if (0 >= c && 0 < b) return b + "\u5206\u949f\u524d";
a = new Date(1E3 * a);
return a.getMonth() + 1 + "\u6708" + a.getDate() + "\u65e5"
}
function msg_info(a) {
new jBox("Notice", {
content: a,
position: {
x: 15,
y: 65
},
zIndex: 12E3,
onInit: function() {
this.options.color = "blue"
}
})
}
function msg_warning(a) {
console.log(a);
new jBox("Notice", {
attributes: {
x: "left",
y: "bottom"
},
theme: "NoticeBorder",
color: "yellow",
animation: {
open: "slide:bottom",
close: "slide:left"
},
onInit: function() {
this.options.color = "yellow";
this.options.title = "\u63d0\u793a";
this.options.content = a
}
})
}
function msg_error(a) {
new jBox("Notice", {
attributes: {
x: "left",
y: "bottom"
},
theme: "NoticeBorder",
color: "red",
animation: {
open: "slide:bottom",
close: "slide:left"
},
onInit: function() {
this.options.color = "red";
this.options.title = "\u9519\u8bef\u8b66\u544a";
this.options.content = a
}
});
console.error(a)
}
imdb = $("#info").find("a[href^='http://www.imdb.com/title/tt']").text();
title_cn = $("#content").children()[0].firstElementChild.textContent.split(" ")[0];
title_en = void 0;
imdb ? imdb.startsWith("tt") && (imdb = imdb.slice(2)) : msg_error("imdb is null");
var linksTable = {
table: void 0,
nodes: [],
init: function() {
var a, b = void 0;
a = $("<div>").attr({
id: "dtable"
});
b = $("<h2>");
b = b.html("\u4e0b\u8f7d\u5730\u5740");
a.append(b);
$($("div.related-info")[0]).after(a);
this.table = $("<table>").attr({
id: "dlinks",
class: "table table-condensed table-hover table-striped"
});
thead = $("<thead>");
a = $("<tr>");
b = $("<th>").attr({
"data-column-id": "copy",
style: "width:33px"
});
b = b.html(" ");
a.append(b);
b = $("<th>").attr({
"data-column-id": "detail",
style: "width:33px"
});
b = b.html(" ");
a.append(b);
b = $("<th>").attr({
"data-column-id": "date",
style: "width:80px"
});
b = b.html("\u65e5\u671f");
a.append(b);
b = $("<th>").attr({
"data-column-id": "type",
style: "width:55px"
});
b = b.html("\u7c7b\u578b");
a.append(b);
b = $("<th>").attr({
"data-column-id": "title"
});
b = b.html("\u540d\u5b57");
a.append(b);
thead.append(a);
this.table.append(thead);
this.table.appendTo($("#dtable"))
},
clean: function() {
$("#dtable").remove();
this.init()
},
_add: function(a) {
thead = $($("#dlinks")[0].firstElementChild);
types = {
0: "mag",
1: "ed2k",
2: "thunder",
3: "netdisk"
};
var b, c = void 0;
b = $("<tr>");
c = $("<th>");
c = c.html('<a href="' + a.detailURL + '" target="_blank" rel="nofollow">\u8be6\u60c5</a>');
b.append(c);
c = $("<th>");
c = c.html('<a onclick="" class="j" href="' + a.downloadURL + '" rel="nofollow">\u590d\u5236</a>');
b.append(c);
c = $("<th>");
c = c.html(a.date);
b.append(c);
c = $("<th>");
c = c.html(types[a.type]);
b.append(c);
c = $("<th>");
c = c.html(a.title);
b.append(c);
thead.append(b)
},
print: function() {
this.clean();
for (i = 0; i < this.nodes.length; i++) this._add(this.nodes[i])
},
refresh: function() {
this.nodes = [];
for (i = 0; i < dmovie.sites.length; i++) this.nodes = this.nodes.concat(dmovie.sites[i].nodes);
this.print()
},
act: function() {
$("#dtable").bootgrid()
}
};
edmag = {
s: title_cn,
nodes: [],
init: function() {
title_cn && (this.url = "http://edmag.net/movie-search-" + this.s + ".html", getDoc(this.url, function(a, b) {
var c = $("tr", a);
for (i = 1; i < c.length; i++) {
var d = c[i],
g = d.getElementsByClassName("magTitle")[0].getElementsByTagName("a")[0],
h = g.getAttribute("href"),
h = "http://edmag.net" + h.slice(1),
g = g.getAttribute("title"),
f = d.getElementsByClassName("time")[0].textContent,
d = d.getElementsByClassName("dow")[0],
e, k = void 0;
try {
k = d.getElementsByClassName("magDown")[0].getAttribute("href")
} catch (l) {}
try {
e = d.getElementsByClassName("ed2kDown")[0].getAttribute("ed2k")
} catch (l) {}
k && (d = {
detailURL: h,
downloadURL: k,
date: f,
type: 0,
title: g
}, edmag.nodes.push(d));
e && (d = {
detailURL: h,
downloadURL: e,
date: f,
type: 1,
title: g
}, edmag.nodes.push(d))
}
edmag.over()
}))
},
over: function() {
msg_info("\u5e76\u5165\t" + this.nodes.length + "\tedmag\u94fe\u63a5");
linksTable.refresh()
}
};
mp4ba = {
s: title_cn,
count: 0,
nodes: [],
init: function() {
title_cn && getDoc("http://www.mp4ba.com/search.php?keyword=" + this.s, function(a) {
a = $("a[href^='show.php?hash=']", a);
mp4ba.count = a.length;
for (i = 0; i < a.length; i++) {
var b = "http://www.mp4ba.com/" + a[i].getAttribute("href");
getDoc(b, function(a, b) {
var g = $("#magnet", a)[0].getAttribute("href"),
h = $("div.location", a)[0].textContent.split("\u00bb").pop(),
h = h.trim(),
f = $("p", a),
e = void 0;
for (i = 0; i < f.length; i++) f[i].textContent.startsWith("\u53d1\u5e03\u65f6\u95f4") && (e = f[i]);
e = e.textContent.slice(5).trim();
mp4ba.nodes.push({
detailURL: b,
downloadURL: g,
date: e,
type: 0,
title: h
});
mp4ba.nodes.length >= mp4ba.count && mp4ba.over()
})
}
a.length || mp4ba.over()
})
},
over: function() {
msg_info("\u5e76\u5165\t" + this.nodes.length + "\t\tmp4ba\u94fe\u63a5");
linksTable.refresh()
}
};
tl95_com = {
s: title_cn,
count: 0,
nodes: [],
init: function() {
title_cn && (url = "http://www.tl95.com/?s=" + this.s, getDoc(url, function(a, b) {
var c = $($("#main", a)[0]).find("a[rel='bookmark'][href]");
tl95_com.count = c.length;
for (i = 0; i < c.length; i++) - 1 === $(c[i]).text().indexOf(tl95_com.s) && (c[i] = void 0, --tl95_com.count);
for (i = 0; i < c.length; i++) c[i] && (b = c[i].getAttribute("href"), getDoc(b, function(a, b) {
tmp = a;
var c = $("div.single-cat", a)[0].textContent.split("\u00a0\u00a0")[0].slice(5),
f = $("a[href^='ed2k']", a);
if (f) for (i = 0; i < f.length; i++) {
n = f[i];
n = $(n);
var e = {
detailURL: b,
downloadURL: n.attr("href"),
date: c,
type: 1,
title: n.text()
};
tl95_com.nodes.push(e)
}
if (f = $("a[href^='thunder']", a)) for (i = 0; i < f.length; i++) n = f[i], n = $(n), e = {
detailURL: b,
downloadURL: n.attr("href"),
date: c,
type: 2,
title: n.text()
}, tl95_com.nodes.push(e);
for (f = /(pan.baidu.com\/s\/[a-zA-Z0-9]+)\s*.+\s*.([a-zA-Z0-9]{4})/g; null !== (e = f.exec(a.body.outerText));) e.index === f.lastIndex && f.lastIndex++, e = {
detailURL: b,
downloadURL: "http://" + (e[1] + "#" + e[2]),
date: c,
type: 3,
title: "\u767e\u5ea6\u7f51\u76d8\uff0c\u5bc6\u7801\u5df2\u5e76\u5165\u94fe\u63a5\u91cc\u3002\u6709\u811a\u672c\u652f\u6301\u81ea\u52a8\u586b\u5165\u3002"
}, tl95_com.nodes.push(e);
tl95_com.nodes.length >= tl95_com.count && tl95_com.over()
}));
c.length || tl95_com.over()
}))
},
over: function() {
msg_info("\u5e76\u5165\t" + this.nodes.length + "\t\ttl95_cpm\u94fe\u63a5");
linksTable.refresh()
}
};
kickass = {
s: imdb,
nodes: [],
init: function() {
imdb && getDoc("https://kat.cr/usearch/imdb:" + this.s, function(a, b) {
var c = $("tbody > tr.odd,tbody > tr.even", a);
for (i = 0; i < c.length; i++) {
var d = c[i],
d = $(d),
g = d.find("a.cellMainLink"),
d = {
detailURL: "https://kat.cr" + g.attr("href"),
downloadURL: d.find("a[href^='magnet']").attr("href"),
date: $(d.find("td[title]")[0]).attr("title"),
type: 0,
title: g.text()
};
kickass.nodes.push(d)
}
kickass.over()
})
},
over: function() {
msg_info("\u5e76\u5165\t" + this.nodes.length + "\t\tkickass\u94fe\u63a5");
linksTable.refresh()
}
};
var dmovie = {
init: function() {
msg_warning("\u8fdb\u5165\u67e5\u8be2\u903b\u8f91");
for (i = 0; i < dmovie.sites.length; i++) this.sites[i].init()
},
sites: [edmag, kickass, mp4ba, tl95_com]
};
linksTable.init();
title_cn || msg_error("title is null");
msg = ["IMDB:\t" + imdb, "TITLE:\t" + title_cn].join("\n");
msg_info(msg);
dmovie.init();