Greasy Fork

Greasy Fork is available in English.

IMDb跳转Rarbg

在IMDb影片页面上添加Rarbg的搜索结果地址

当前为 2022-09-06 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         IMDb跳转Rarbg
// @namespace    https://gist.github.com/LandonLi
// @version      2.1
// @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 + '" tabindex="0" class="ipc-link ipc-link--baseAlt ipc-link--inherit-color">Rarbg</a></li>');
    var ul = document.evaluate('//div[@data-testid="hero-subnav-bar-right-block"]/ul', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue
    ul.appendChild(rarbgLink);
    console.log("已添加Rarbg跳转");
})();