Skip to content

Instantly share code, notes, and snippets.

@adamharley
Created March 7, 2015 14:31
Show Gist options
  • Save adamharley/5ba036ffadef2bd0a0ae to your computer and use it in GitHub Desktop.
Save adamharley/5ba036ffadef2bd0a0ae to your computer and use it in GitHub Desktop.
4chan magnet links extension
{
"manifest_version": 2,
"name": "4chan magnet links",
"description": "",
"version": "0.1",
"content_scripts": [
{
"matches": [
"http://boards.4chan.org/*"
],
"js": ["parse.js"],
"run_at": "document_end"
}
]/*,
"icons": { "16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png" }
*/
}
var postMessages = document.querySelectorAll(".postMessage");
[].forEach.call(postMessages, function(postMessage) {
var lines = postMessage.innerHTML.split("<br>");
lines.forEach(function(line, i){
if (line.substr(0,7) == 'magnet:') {
var dnIndex = line.indexOf("&amp;dn=");
var title = dnIndex ? ' for ' + decodeURIComponent(line.substr(dnIndex + 8)) : '';
lines[i] = '<a href="' + line + '">Magnet' + title + '</a>';
}
});
postMessage.innerHTML = lines.join('<br>');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment