Skip to content

Instantly share code, notes, and snippets.

@lisposter
Created August 3, 2015 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lisposter/2533147437f61c17e6ce to your computer and use it in GitHub Desktop.
Save lisposter/2533147437f61c17e6ce to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name btdigg.org bulk copy
// @namespace http://zhu.li/
// @version 0.1
// @description fast select and copy magnet
// @author Leigh Zhu
// @match http://btdigg.org/search?*
// @grant none
// ==/UserScript==
;(function(window, document) {
var magentLinks = Array.prototype.slice.call(document.querySelectorAll('a[href^=magnet]'))
.map(function(itm) {
return itm.href;
});
function parseLinks(links) {
return links.map(function(itm) {
var params = {};
itm.split('?')[1].split('&').forEach(function(kv) {
var tmp = {};
params[kv.split('=')[0]] = kv.split('=')[1];
});
return {
dn: decodeURIComponent(params.dn || ''),
magnet: itm
}
})
}
console.log(magentLinks);
console.log(parseLinks(magentLinks))
})(window, document);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment