Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

Commit

Permalink
First version
Browse files Browse the repository at this point in the history
  • Loading branch information
Niamor committed Apr 3, 2016
1 parent 50d9f94 commit 0eb9916
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.xpi
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# nyaa-magnet-links
Firefox WebExtension to add magnet links on NyaaTorrents.

![screenshot](https://files.catbox.moe/35nx0x.png)
![screenshot](https://files.catbox.moe/om9xqy.png)
Binary file added icons/magnet-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/magnet-26.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/magnet-48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

const parseTorrent = require('parse-torrent');

if (!location.search || location.search === -1 ||
location.search.indexOf('page=search') !== -1) {
$(() => {
$('[title="Download"]').each((i, el) => {
const elem = $(el);
parseTorrent.remote(location.protocol + elem.attr('href'), (err, parsedTorrent) => {
const magnetButton = $('<a/>', {
title: 'Magnet',
href: parseTorrent.toMagnetURI(parsedTorrent)
}).append($('<img/>', {
src: chrome.extension.getURL('icons/magnet-16.png'),
alt: 'Magnet'
}));
elem.before(magnetButton);
});
});
});
} else if (location.search.indexOf('page=view') !== -1) {
const button = $('.viewdownloadbutton');
parseTorrent.remote(location.protocol + button.find('a').attr('href'), (err, parsedTorrent) => {
const magnetButton = $('<div/>', {
class: 'viewdownloadbutton'
}).append($('<a/>', {
title: 'Magnet',
href: parseTorrent.toMagnetURI(parsedTorrent)
}).append($('<img/>', {
src: chrome.extension.getURL('icons/magnet-26.png'),
alt: 'Magnet'
})));
button.after(magnetButton);
});
}
4 changes: 4 additions & 0 deletions lib/jquery-2.2.2.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions lib/parse-torrent.min.js

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"manifest_version": 2,
"name": "Nyaa Magnet Links",
"version": "0.1.0",

"description": "Add magnet links on NyaaTorrents",
"homepage_url": "https://github.com/Niamor/nyaa-magnet-links",
"icons": {
"48": "icons/magnet-48.png"
},

"applications": {
"gecko": {
"id": "@nyaa-magnet-links",
"strict_min_version": "45.0.0"
}
},

"content_scripts": [{
"matches": ["*://*.nyaa.se/*"],
"js": ["lib/jquery-2.2.2.min.js", "lib/parse-torrent.min.js", "index.js"]
}],

"web_accessible_resources": ["icons/magnet-16.png", "icons/magnet-26.png"]
}

0 comments on commit 0eb9916

Please sign in to comment.