Created
August 3, 2015 05:49
-
-
Save lisposter/2533147437f61c17e6ce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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