Douban2Piratebay/Douban2Piratebay.user.js

55 lines
1.9 KiB
JavaScript
Raw Normal View History

2017-05-13 14:00:36 +08:00
// ==UserScript==
// @name Douban2Piratebay
2017-05-13 14:30:44 +08:00
// @namespace https://github.com/bitdust/Douban2Piratebay/
2017-05-13 15:56:20 +08:00
// @version 0.5
2017-05-13 14:00:36 +08:00
// @description And direct link to piratebay from douban movie page.
// @author bitdust
// @match https://movie.douban.com/subject/*
2017-05-13 15:08:33 +08:00
// @updateURL https://raw.githubusercontent.com/bitdust/Douban2Piratebay/master/Douban2Piratebay.meta.js
// @downloadURL https://raw.githubusercontent.com/bitdust/Douban2Piratebay/master/Douban2Piratebay.user.js
2017-05-13 14:00:36 +08:00
// @grant none
// ==/UserScript==
(function() {
'use strict';
function insertAfter(newNode, referenceNode) {
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}
2017-05-13 15:56:20 +08:00
2017-05-13 14:00:36 +08:00
var links = document.querySelectorAll (
"#info > a"
);
var imdblink = null;
var imdbRe = new RegExp("tt[0-9]{4,}");
2017-06-04 23:42:54 +08:00
for (var i=0; i<links.length; i++) {
2017-05-13 14:00:36 +08:00
if(imdbRe.test(links[i].textContent)) {
imdblink = links[i];
break;
}
}
2017-05-13 15:56:20 +08:00
2017-06-04 23:42:54 +08:00
function addLink(name, href){
let imdbindex = imdblink.innerText;
let fragment = document.createDocumentFragment();
let br = document.createElement("br");
let parent = imdblink.parentElement;
let span = imdblink.previousElementSibling.cloneNode(false);
span.textContent = name + "链接: ";
let a = imdblink.cloneNode(true);
a.textContent = "下载";
a.href = href + imdbindex;
2017-05-13 14:00:36 +08:00
fragment.appendChild(br);
fragment.appendChild(span);
fragment.appendChild(a);
insertAfter(fragment, imdblink);
}
2017-06-04 23:42:54 +08:00
if (imdblink !== null) {
addLink("电影天堂", 'http://www.btrr.net/tag/');
addLink("HD湾", 'http://www.hdwan.net/?s=');
addLink("RARGB", 'https://rarbgmirror.com/torrents.php?imdb=');
addLink("海盗湾", 'https://thepiratebay.org/search/');
}
2017-05-13 14:00:36 +08:00
})();