diff --git a/arxivvanityplugin.zip b/arxivvanityplugin.zip deleted file mode 100644 index a59ee8b..0000000 Binary files a/arxivvanityplugin.zip and /dev/null differ diff --git a/arxivvanitypluginv2.zip b/arxivvanitypluginv2.zip new file mode 100644 index 0000000..07740a3 Binary files /dev/null and b/arxivvanitypluginv2.zip differ diff --git a/background.js b/background.js new file mode 100644 index 0000000..8ded896 --- /dev/null +++ b/background.js @@ -0,0 +1,25 @@ +chrome.browserAction.onClicked.addListener(function(tab) { + chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { + var tab = tabs[0]; + + // extract url and return if doesn't match + url = tab.url; + if(!url.startsWith('https://arxiv.org/') ) { + return; + } + + // get arxiv iv + re = /(\d+\.\d+v?\d)/i + found = url.match(re)[0] + + // construct new url + vanity = "http://www.arxiv-vanity.com/papers/" + found + + // navigate to vanity + chrome.tabs.create({ + url: vanity, + index: tab.index + 1, + active: true, + }); + }); +}); diff --git a/manifest.json b/manifest.json index 53c3a01..8646594 100644 --- a/manifest.json +++ b/manifest.json @@ -3,15 +3,17 @@ "name": "Arxiv Vanity Plugin", "description": "This extension provides an arxiv vanity link directly on an accessed arxiv page.", - "version": "1.0", + "version": "1.1", + "background" : { + "scripts" : ["background.js"] + }, "browser_action": { - "default_icon": "arxivchrome.png", - "default_popup": "popup.html" + "default_icon": "arxivchrome.png" }, "permissions": [ "activeTab", - "storage", + "tabs", "*://*.arxiv.org/*" ], "content_scripts": [ diff --git a/popup.html b/popup.html deleted file mode 100644 index ef64f46..0000000 --- a/popup.html +++ /dev/null @@ -1,32 +0,0 @@ - - - -
-Arxiv Vanity originally by Andreas Jansson and Ben Firshman
- - diff --git a/popup.js b/popup.js deleted file mode 100644 index e69de29..0000000