Skip to content

Instantly share code, notes, and snippets.

@defektive
Last active August 29, 2015 14:02
Show Gist options
  • Save defektive/1012be815a89cbe294a0 to your computer and use it in GitHub Desktop.
Save defektive/1012be815a89cbe294a0 to your computer and use it in GitHub Desktop.
pirate bay categories to json map - run this on the browse page
(function () {
var categoryLinks = document.querySelectorAll("#categoriesTable a"),
categoryMap = {},
link, name, id, currentParentCat, key;
for(var i = 0; i < categoryLinks.length; i++) {
link = categoryLinks[i];
if(link.href.indexOf("browse") !== -1) {
name = link.textContent;
id = parseInt(link.href.replace(/[^0-9]/g, ''), 0);
if(id % 100 === 0) {
key = parent = name;
} else {
key = parent + "/" + name;
}
categoryMap[key] = id;
}
}
console.log(JSON.stringify(categoryMap));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment