├── icon128.png ├── icon_nope128.png ├── _metadata └── generated_indexed_rulesets │ ├── _ruleset1 │ └── _ruleset2 ├── arxiv_to_ar5iv.json ├── ar5iv_to_arxiv.json ├── README.md ├── manifest.json └── background.js /icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yobibyte/ar5iv_chrome_ext/HEAD/icon128.png -------------------------------------------------------------------------------- /icon_nope128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yobibyte/ar5iv_chrome_ext/HEAD/icon_nope128.png -------------------------------------------------------------------------------- /_metadata/generated_indexed_rulesets/_ruleset1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yobibyte/ar5iv_chrome_ext/HEAD/_metadata/generated_indexed_rulesets/_ruleset1 -------------------------------------------------------------------------------- /_metadata/generated_indexed_rulesets/_ruleset2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yobibyte/ar5iv_chrome_ext/HEAD/_metadata/generated_indexed_rulesets/_ruleset2 -------------------------------------------------------------------------------- /arxiv_to_ar5iv.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 1, 4 | "priority": 1, 5 | "action": { 6 | "type": "redirect", 7 | "redirect": { 8 | "regexSubstitution": "https://ar5iv.org/pdf/" 9 | } 10 | }, 11 | "condition": { 12 | "regexFilter": "^https://(www\\.)?arxiv\\.org/pdf/", 13 | "resourceTypes": ["main_frame"] 14 | } 15 | } 16 | ] 17 | -------------------------------------------------------------------------------- /ar5iv_to_arxiv.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 1, 4 | "priority": 1, 5 | "action": { 6 | "type": "redirect", 7 | "redirect": { 8 | "regexSubstitution": "https://arxiv.org/pdf/" 9 | } 10 | }, 11 | "condition": { 12 | "regexFilter": "^https://(www\\.)?ar5iv(\\.labs\\.arxiv)?\\.org/html/", 13 | "resourceTypes": ["main_frame"] 14 | } 15 | } 16 | ] 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Automatic arxiv->ar5iv link replacement in Chrome. 2 | 3 | This chrome extension will automatically replace arxiv.org/pdf/* links with ar5iv links for more web-friendly reading. Additionally, clicking on the extension's icon will take you to the alternate version. 4 | 5 | ## Installation 6 | 7 | simply download [here](https://chrome.google.com/webstore/detail/arxiv-%3Ear5iv/ledhlnbblmkmfdckpmolbpocibcanfda) 8 | 9 | ## Usage 10 | 11 | The extension will automatically replace arxiv pdf links with ar5iv html links per default. 12 | You can click the extension's icon to toggle this behavior. 13 | 14 | - if the icon is crossed out, the extension will always load pdfs (replace ar5iv html links with arxiv pdf links). 15 | - if the icon is not crossed out, the extension will always load html (replace arxiv pdf links with ar5iv html links). 16 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "arxiv -> ar5iv", 3 | "description": "Automatically replace arxiv links with ar5iv", 4 | "version": "1.0.0.2", 5 | "manifest_version": 3, 6 | "background": { 7 | "service_worker": "background.js" 8 | }, 9 | "action": { 10 | "default_icon": "icon128.png" 11 | }, 12 | "permissions": [ 13 | "storage", 14 | "declarativeNetRequestWithHostAccess" 15 | ], 16 | "host_permissions": [ 17 | "*://arxiv.org/*", 18 | "*://www.arxiv.org/*", 19 | "*://ar5iv.org/*", 20 | "*://ar5iv.labs.arxiv.org/*", 21 | "*://www.ar5iv.org/*" 22 | ], 23 | "declarative_net_request": { 24 | "rule_resources": [{ 25 | "id": "arxiv_to_ar5iv", 26 | "enabled": true, 27 | "path": "arxiv_to_ar5iv.json" 28 | }, 29 | { 30 | "id": "ar5iv_to_arxiv", 31 | "enabled": true, 32 | "path": "ar5iv_to_arxiv.json" 33 | }] 34 | }, 35 | "icons": {"128": "icon128.png"} 36 | } 37 | -------------------------------------------------------------------------------- /background.js: -------------------------------------------------------------------------------- 1 | var isEnabled = true; 2 | chrome.storage.sync.get(/* String or Array */["ar5iv_enabled"], function(result){ 3 | isEnabled = result.ar5iv_enabled; 4 | }); 5 | 6 | const setIcon = function(){ 7 | chrome.action.setIcon({path: isEnabled ? "icon128.png" : "icon_nope128.png"}); 8 | } 9 | 10 | const storeSetting = function(){ 11 | chrome.storage.sync.set({ar5iv_enabled: isEnabled}, function(){}); 12 | } 13 | 14 | // When the extension icon is clicked, switch back to pdf / ar5iv 15 | var switch_view = function(tab) { 16 | if (!isEnabled) { // arxiv -> ar5iv 17 | chrome.declarativeNetRequest.updateEnabledRulesets({enableRulesetIds: ["arxiv_to_ar5iv"], disableRulesetIds: ["ar5iv_to_arxiv"]}, function() {}); 18 | } else { // ar5iv -> arxiv 19 | chrome.declarativeNetRequest.updateEnabledRulesets({enableRulesetIds: ["ar5iv_to_arxiv"], disableRulesetIds: ["arxiv_to_ar5iv"]}); 20 | } 21 | isEnabled ^= true; 22 | setIcon(); 23 | storeSetting(); 24 | if (tab.url.match(/^https:\/\/(www\.)?(ar5iv\.labs\.)?ar(x|5)iv\.org\/((pdf)|(html))/)) { 25 | chrome.tabs.reload(tab.id); 26 | } 27 | } 28 | chrome.action.onClicked.addListener(tab => switch_view(tab)); --------------------------------------------------------------------------------