Skip to content

Instantly share code, notes, and snippets.

@joest67
Created January 18, 2014 02:27
Show Gist options
  • Save joest67/8485350 to your computer and use it in GitHub Desktop.
Save joest67/8485350 to your computer and use it in GitHub Desktop.
When you find a wonderful movie in douban, this script will automatic search its torrent from bt.byr.cn.
// ==UserScript==
//
// @name byr_bt
// @description Search movies on bt which you see in douban
// @namespace http://bt.byr.cn/
// @author joest(chaojiong.zheng@gmail.com)
// @license GNU GPL v3 (http://www.gnu.org/copyleft/gpl.html)
// @version 1.0
// @include http://movie.douban.com/subject/*
//
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js
//
//
// ==/UserScript==
var searchurl='http://bt.byr.cn/torrents.php?';
// 可以通过安装查看cookie的插件获得
var c_secure_uid=""
var c_secure_pass=""
var c_secure_login=""
function insertloading(){
var htmlstr = '<div id="btinfo" class="gray_ad"><h2>北邮人BT查询</h2></div>';
$('.aside').prepend(htmlstr);
}
//获取title
function page_subject(){
//insert load info
insertloading();
// get movie name
title = $('h1>span').text();
var stop = title.indexOf(' ');
if (stop == -1)
{
stop = title.indexOf('(');
}
if (stop != -1)
{
title = title.substring(0, stop);
}
searchurl += "incldead=0&spstate=0&inclbookmarked=0&search=" + title +"&search_area=0&search_mode=0";
getMovieInfo();
}
function getMovieInfo(){
setTimeout(function(){GM_xmlhttpRequest({
method: 'GET',
url: searchurl,
headers: {
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
"Cookie": 'c_secure_uid=' + c_secure_uid + '; c_secure_pass=' + c_secure_pass + '; c_secure_login=' + c_secure_login
},
onload: function(responseDetails) {
var responses=responseDetails.responseText;
var strHtml=null;
if(responses.indexOf("没有种子") != -1)
{
strHtml = "没有种子</br>";
}
else
{
var link = searchurl;
strHtml = "有种子 => <a href='" + link + "' target='_blank'>详情</a></br>";
}
appendInfo(strHtml);
}
})},500);
}
function appendInfo(value){
$("#btinfo").append(value);
}
$(document).ready(function(){
page_subject();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment