// ==UserScript==
// @name Movie CSE for douban
// @name:zh-CN 豆瓣电影自定义搜索
// @namespace http://www.einverne.tk
// @version 1.3
// @description find useful movie download link from Google Custom Search Engine
// @description:zh-cn 利用Google自定义搜索引擎给豆瓣电影加上下载链接
// @match http://movie.douban.com/subject/*
// @copyright 2014+, einverne
// @downloadURL https://update.greasyfork.icu/scripts/7915/Movie%20CSE%20for%20douban.user.js
// @updateURL https://update.greasyfork.icu/scripts/7915/Movie%20CSE%20for%20douban.meta.js
// ==/UserScript==
(function () {
var nextpage_index = 0;
var url;
var keyword2;
var cx = "013193653470345952139:rmavzl75vbq";
var CSEFunction = function () {
console.log("CSEFunction");
var douban_url = this.location.href;
var reg = /(\d{7,8})/g; //正則
var douban_id = douban_url.match(reg); //獲取movie id
var title = $('html head title').text();
var keyword1 = title.replace('(豆瓣)', '').trim();
keyword2 = encodeURIComponent(keyword1);
var html_title_start = '
';
}
var html_body = html_body_start + html_body_yes + html_body_end;
$("#movie_cse>.csecontent").replaceWith(html_body);
//$('.aside').prepend(html_title + html_body_start + html_body_yes + html_body_end + html_body_endmore + html_body_endend);
} else {
//$('.aside').prepend(html_title + html_body_start + html_body_no + html_body_end + html_body_endend);
}
}
});
}
}
function contentEval(source) {
console.log("contentEval");
// Check for function input.
if ('function' == typeof source) {
// Execute this function with no arguments, by adding parentheses.
// One set around the function, required for valid syntax, and a
// second empty set calls the surrounded function.
source = '(' + source + ')();'
}
// Create a script node holding this source code.
var script = document.createElement('script');
script.setAttribute("type", "application/javascript");
script.textContent = source;
// Insert the script node into the page, so it will run, and immediately
// remove it to clean up.
document.body.appendChild(script);
document.body.removeChild(script);
}
contentEval(CSEFunction());
}());