mirror of
https://github.com/wassname/Chrome-Arxiv-Vanity.git
synced 2026-06-27 16:58:52 +08:00
Added button click feature
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -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
@@ -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
@@ -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>
|
|
||||||
Reference in New Issue
Block a user