Added button click feature

This commit is contained in:
isaykatsman
2017-10-25 18:45:00 -04:00
parent 0a8fbee09e
commit d3d1f0e72a
6 changed files with 31 additions and 36 deletions
Binary file not shown.
Binary file not shown.
+25
View File
@@ -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,
});
});
});
+6 -4
View File
@@ -3,15 +3,17 @@
"name": "Arxiv Vanity Plugin", "name": "Arxiv Vanity Plugin",
"description": "This extension provides an arxiv vanity link directly on an accessed arxiv page.", "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": { "browser_action": {
"default_icon": "arxivchrome.png", "default_icon": "arxivchrome.png"
"default_popup": "popup.html"
}, },
"permissions": [ "permissions": [
"activeTab", "activeTab",
"storage", "tabs",
"*://*.arxiv.org/*" "*://*.arxiv.org/*"
], ],
"content_scripts": [ "content_scripts": [
-32
View File
@@ -1,32 +0,0 @@
<!doctype html>
<!--
This page is shown when the extension button is clicked, because the
"browser_action" field in manifest.json contains the "default_popup" key with
value "popup.html".
-->
<html>
<head>
<title>Arxiv Vanity Plugin</title>
<style type="text/css">
body {
margin: 10px;
white-space: nowrap;
}
h1 {
font-size: 15px;
}
#container {
align-items: center;
display: flex;
justify-content: space-between;
}
</style>
</head>
<body>
<h1>Arxiv Vanity Plugin</h1>
<p>Arxiv Vanity originally by Andreas Jansson and Ben Firshman</p>
</body>
</html>
View File