Skip to content

Instantly share code, notes, and snippets.

@ZikiSoy
Created September 13, 2015 09:28
Show Gist options
  • Save ZikiSoy/fc4449bd82aa64588c99 to your computer and use it in GitHub Desktop.
Save ZikiSoy/fc4449bd82aa64588c99 to your computer and use it in GitHub Desktop.
scripts
// ==UserScript==
// @name BtBook Utilities
// @namespace http://github.com/zikisoy
// @version 0.1
// @description Add magnet link to BtBook!
// @author hmmm
// @match http://www.btbook.net/search/*
// @require https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// @grant GM_xmlhttpRequest
// @grant GM_openInTab
// @copyright 2014+, ZikiSoy
// ==/UserScript==
// a function that loads jQuery and calls a callback function when jQuery has finished loading
function addJQuery(callback) {
var script = document.createElement("script");
//script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
script.setAttribute("src", "//code.jquery.com/jquery-1.11.0.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
document.body.appendChild(script);
});
document.body.appendChild(script);
}
addJQuery(function(){});
var jQ=jQuery.noConflict(true);
jQ('.download').css('display', 'inline');
/*
jQ('.item-title a').each(function() {
var it = jQ(this);
var link = it.attr('href');
var pat = /detail\/(.*)\.html$/
var hs = pat.exec(link);
console.log(hs);
if (hs[1]) {
it.after(' <a href="magnet:?xt=urn:btih:' + hs[1] + '">Download</a>');
}
})
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment