Skip to content

Instantly share code, notes, and snippets.

@binux
Created July 19, 2012 07:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save binux/3141405 to your computer and use it in GitHub Desktop.
Save binux/3141405 to your computer and use it in GitHub Desktop.
export thunder lixian url to aria2/wget
// ==UserScript==
// @name ThunderLixianExporter
// @namespace http://binux.me/
// @version 0.1
// @description export thunder lixian url to aria2/wget
// @match http://dynamic.cloud.vip.xunlei.com/user_task?*
// @run-at document-end
// @copyright 2012+, You
// ==/UserScript==
(function(TLE) {
function create_dom(html_str) {
var div = document.createElement('div');
div.innerHTML = html_str;
return div.childNodes[0];
};
function insert_after(elem, _this) {
_this.parentNode.insertBefore( elem, _this.nextSibling );
};
function TLE_parser(_this, _do) {
a=_this;
b=_do;
var p = $(_this).parents(".rw_list");
var taskid = p.attr("taskid");
var info = {};
p.find("input").each(function(n, e) {
var key = e.getAttribute("id").replace(taskid, "");
info[key] = e.getAttribute("value");
});
console.log(info);
};
var style = document.createElement('style');
style.textContent = '.TLE_get_btnbox {position:relative; float:left; z-index:11}\n'
+ '.TLE_get_btnbox .TLE_p_getbtn {position: absolute; top:24px; left:0; border:1px #6FB2F3 solid; background:#fff; width:115px;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;-moz-box-shadow:2px 2px 3px #ddd;-webkit-box-shadow:2px 2px 3px #ddd;}\n'
+ '.TLE_get_btnbox .TLE_p_getbtn a {display:block; height:22px; line-height:22px; padding-left:18px}\n'
+ '.TLE_get_btnbox .TLE_p_getbtn a:hover {background:#E4EFF9 url(http://cloud.vip.xunlei.com/190/img/ic_dianbo.png) no-repeat 8px 8px; *background-position:8px 6px ; text-decoration:none}\n'
+ '.TLE_get_btnbox .TLE_getlink {width:98px; height:22px; float:left; line-height:21px;*line-height:24px;display:block;color:#000000; margin-right:5px; overflow:hidden;background:url(http://cloud.vip.xunlei.com/190/img/bg_btnall.png?197) no-repeat 0 -390px}\n'
+ '.TLE_get_btnbox .TLE_link_gettxt {float:left; display: inline ; width:53px; text-align:center; padding-left:24px; color:#000}\n'
+ '.TLE_get_btnbox .TLE_link_gettxt:hover{ text-decoration:none}\n'
+ '.rwbox .rwset .TLE_link_getic {float:left; display:block; width:20px;height:22px;}\n'
+ '.TLE_hiden { display: none; }\n'
+ '.rwbtn.ic_redownloca { display: none !important; }\n'
document.head.appendChild(style);
var down_btns = document.querySelectorAll(".rwbtn.ic_redownloca");
for (var i=0, l=down_btns.length; i<l; i++) {
down_btns[i].setAttribute("style", "display: none;");
insert_after(create_dom('<div class="TLE_get_btnbox">'
+ '<span class="TLE_getlink">'
+ '<a href="#" class="TLE_link_gettxt TLE-down-text" style="padding-left: 20px; width: 57px;" onclick='+down_btns[i].getAttribute("onclick")+'>取回本地</a>'
+ '<a href="#" class="TLE_link_getic TLE-down-btn" onclick="return J_getbtn(this);"></a>'
+ '</span>'
+ '<div class="TLE_p_getbtn" style="display: none;">'
+ '<a href="#" title="aria2" onmouseover="this.className=\'sel_on\'" onmouseout="this.className=\'\'" onclick="TLE_parser(this, \'aria2\')">Aria2</a>'
+ '<a href="#" title="wget" onmouseover="this.className=\'sel_on\'" onmouseout="this.className=\'\'" onclick="TLE_parser(this, \'wget\')">wget</a>'
+ '</div>'
+ '</div>'),
down_btns[i]);
};
var script = document.createElement('script');
script.text = 'function J_getbtn(_this) { var p=$(_this).parents(".TLE_get_btnbox");p.find(".TLE_p_getbtn").toggle();p.find("p_yunbtn").hide();close_rightmenu_layer();return false; };\n'
+'$(document.body).bind("click",function(){$("div.TLE_p_getbtn").hide();});\n'
+'$("div.rw_list").click(function(e){$(".TLE_p_getbtn").hide()});\n'
+'$("div.TLE_get_btnbox").click(function(e){e.stopPropagation();});\n'
+String(TLE_parser)
//+'TLE_close_rightmenu_layer = close_rightmenu_layer;close_rightmenu_layer = function(){TLE_close_rightmenu_layer();$(".TLE_p_getbtn").hide();};\n'
document.head.appendChild(script);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment