Greasy Fork is available in English.
在IMDb影片页面上添加Rarbg的搜索结果地址
当前为
// ==UserScript==
// @name IMDb跳转Rarbg
// @namespace https://gist.github.com/LandonLi
// @version 2.0
// @description 在IMDb影片页面上添加Rarbg的搜索结果地址
// @author Landon Li
// @icon https://ia.media-imdb.com/images/G/01/imdb/images/favicon-2165806970
// @match *://www.imdb.com/title/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function htmlToElement(html) {
var template = document.createElement('template');
html = html.trim(); // Never return a text node of whitespace as the result
template.innerHTML = html;
return template.content.firstChild;
}
// 从当前页面url中获取imdbID
var parts = window.location.href.split('/');
var imdbID = parts[parts.length-2];
console.log("imdbID:" + imdbID);
// 拼接Rarbg的搜索地址
var rarbgUrl = "https://rarbg.to/torrents.php?search=" + imdbID;
// 在页面添加一键链接
var rarbgLink = htmlToElement('<li role="presentation" class="ipc-inline-list__item"><a href="' + rarbgUrl + '" class="ipc-link ipc-link--baseAlt ipc-link--inherit-color">Rarbg</a></li>');
var ul = document.evaluate('//div[contains(@class, "SubNav__SubNavContainer")]/div[1]/div[2]/ul', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue
ul.appendChild(rarbgLink);
console.log("已添加Rarbg跳转");
})();