Fix: less insert operation.

This commit is contained in:
bitdust 2017-06-06 13:27:58 +08:00
parent 819f24eff3
commit 7c96e524ba
2 changed files with 21 additions and 22 deletions

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name Douban2Piratebay // @name Douban2Piratebay
// @namespace https://github.com/bitdust/Douban2Piratebay/ // @namespace https://github.com/bitdust/Douban2Piratebay/
// @version 0.5 // @version 0.6
// @description And direct link to piratebay from douban movie page. // @description And direct link to piratebay from douban movie page.
// @author bitdust // @author bitdust
// @match https://movie.douban.com/subject/* // @match https://movie.douban.com/subject/*

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name Douban2Piratebay // @name Douban2Piratebay
// @namespace https://github.com/bitdust/Douban2Piratebay/ // @namespace https://github.com/bitdust/Douban2Piratebay/
// @version 0.5 // @version 0.6
// @description And direct link to piratebay from douban movie page. // @description And direct link to piratebay from douban movie page.
// @author bitdust // @author bitdust
// @match https://movie.douban.com/subject/* // @match https://movie.douban.com/subject/*
@ -17,6 +17,13 @@
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); 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 ( var links = document.querySelectorAll (
"#info > a" "#info > a"
); );
@ -29,26 +36,18 @@
} }
} }
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;
fragment.appendChild(br);
fragment.appendChild(span);
fragment.appendChild(a);
insertAfter(fragment, imdblink);
}
if (imdblink !== null) { if (imdblink !== null) {
addLink("电影天堂", 'http://www.btrr.net/tag/'); var imdbindex = imdblink.innerText;
addLink("HD湾", 'http://www.hdwan.net/?s='); var fragment = document.createDocumentFragment();
addLink("RARGB", 'https://rarbgmirror.com/torrents.php?imdb='); var br = document.createElement("br");
addLink("海盗湾", 'https://thepiratebay.org/search/'); 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?imdb=' + imdbindex);
addLink(fragment, "HD湾 ", 'http://www.hdwan.net/?s=' + imdbindex);
addLink(fragment, "电影天堂 ", 'http://www.btrr.net/?s=' + imdbindex);
insertAfter(fragment, imdblink);
} }
})(); })();