HDBits torrent search

Searches for torrents with the same name as the current one

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name			HDBits torrent search
// @namespace		https://greasyfork.org/users/19952-xant1k-bt
// @description		Searches for torrents with the same name as the current one
// @include			https://hdbits.org/details.php?id=*
// @version			1.0
// @author			deva
// ==/UserScript==

title = document.getElementsByTagName('h1')[0];

titleString = new String(title.innerHTML);

searchLink = document.createElement('a');

searchLink.innerHTML = 'search on HDBits';

if(titleString.match(/s[0-9][0-9]e[0-9][0-9]/i) != null){// show

    titleString = titleString.match(/^(.*?)( -)? s[0-9][0-9]e[0-9][0-9]/i)[1];

}else if(titleString.match(/ - /i) != null){

    titleString = titleString.match(/^(.*?) - /i)[1];

}// else just use original string

searchLink.href='browse.php?search='+titleString;

searchLink.title = 'search HDBits for "' + titleString + '"';

table = myNextSibling(title);

tbody = myFirstChild(table);

linkTD = tbody.firstChild.firstChild.nextSibling;

linkTD.appendChild(document.createTextNode(' | '));

linkTD.appendChild(searchLink);

// helping functions

function myFirstChild(obj){

    temp = obj.firstChild;

    while(temp.nodeType == 3){    //TEXT_NODE = 3

        temp = temp.nextSibling;

    }

    return temp;

}

function myNextSibling(obj){

    temp = obj.nextSibling;

    while(temp.nodeType == 3){    //TEXT_NODE = 3

        temp = temp.nextSibling;

    }

    return temp;

}