HDBits torrent search

Searches for torrents with the same name as the current one

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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;

}