-
Notifications
You must be signed in to change notification settings - Fork 22
/
Douban2Piratebay.user.js
51 lines (46 loc) · 1.73 KB
/
Douban2Piratebay.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// ==UserScript==
// @name Douban2Piratebay
// @namespace https://github.com/bitdust/Douban2Piratebay/
// @version 0.7
// @description And direct link to piratebay from douban movie page.
// @author bitdust
// @match https://movie.douban.com/subject/*
// @updateURL https://raw.githubusercontent.com/bitdust/Douban2Piratebay/master/Douban2Piratebay.meta.js
// @downloadURL https://raw.githubusercontent.com/bitdust/Douban2Piratebay/master/Douban2Piratebay.user.js
// @grant none
// ==/UserScript==
(function() {
'use strict';
function insertAfter(newNode, referenceNode) {
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}
function addLink(fragment, text, href){
let a = imdblink.cloneNode(true);
a.textContent = text;
a.href = href;
fragment.appendChild(a);
}
var links = document.querySelectorAll (
"#info > a"
);
var imdblink = null;
var imdbRe = new RegExp("tt[0-9]{4,}");
for (var i=0; i<links.length; i++) {
if(imdbRe.test(links[i].textContent)) {
imdblink = links[i];
break;
}
}
if (imdblink !== null) {
var imdbindex = imdblink.innerText;
var fragment = document.createDocumentFragment();
var br = document.createElement("br");
var span = imdblink.previousElementSibling.cloneNode(false);
span.textContent = "资源:";
fragment.appendChild(br);
fragment.appendChild(span);
addLink(fragment, "TPB ", 'https://thepiratebay.org/search/' + imdbindex);
addLink(fragment, "RARGB ", 'https://rarbgmirror.com/torrents.php?search=' + imdbindex);
insertAfter(fragment, imdblink);
}
})();