├── images ├── icon.png └── screenshot.png ├── Makefile ├── manifest.json ├── LICENSE ├── README.md └── scripts └── inject.js /images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amitness/open-in-overleaf/HEAD/images/icon.png -------------------------------------------------------------------------------- /images/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amitness/open-in-overleaf/HEAD/images/screenshot.png -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | zip: 2 | rm -rf open-in-overleaf.zip 3 | zip -r open-in-overleaf.zip images/*.png scripts/* manifest.json LICENSE -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "open-in-overleaf", 3 | "version": "0.1.2", 4 | "description": "Access the LaTeX source code of arXiv papers on Overleaf ", 5 | "author": "Amit Chaudhary ", 6 | "homepage_url": "https://github.com/amitness/open-in-overleaf", 7 | "manifest_version": 3, 8 | "content_scripts": [ 9 | { 10 | "matches": [ 11 | "https://arxiv.org/abs/*", 12 | "http://arxiv.org/abs/*" 13 | ], 14 | "js": [ 15 | "scripts/inject.js" 16 | ], 17 | "run_at": "document_end" 18 | } 19 | ], 20 | "icons": { 21 | "144": "images/icon.png" 22 | }, 23 | "offline_enabled": true 24 | } 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Amit Chaudhary 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # open-in-overleaf [![Chrome Web Store](https://img.shields.io/chrome-web-store/users/oikhlgfcmfbbdjbeeaplalpfdgijbdji?label=users)](https://chromewebstore.google.com/detail/open-in-overleaf/oikhlgfcmfbbdjbeeaplalpfdgijbdji?pli=1) [![](https://img.shields.io/chrome-web-store/rating/oikhlgfcmfbbdjbeeaplalpfdgijbdji.svg)](https://chromewebstore.google.com/detail/open-in-overleaf/oikhlgfcmfbbdjbeeaplalpfdgijbdji?pli=1) 4 | 5 | A browser extension to open and edit any arxiv.org paper directly on overleaf. 6 | 7 | https://github.com/amitness/open-in-overleaf/assets/8587189/faaf9ce9-3ab1-410b-af26-dd17afc32211 8 | 9 | 10 | 11 | This is useful to examine how some feature or typesetting effect in a paper was implemented in LaTex. It's also useful to copy equations, citations and tables from the paper for derivative work or presentations. 12 | 13 | ## Install 14 | - [Chrome Web Store](https://chrome.google.com/webstore/detail/open-in-overleaf/oikhlgfcmfbbdjbeeaplalpfdgijbdji) 15 | 16 | ## Usage 17 | On the arxiv page, click `Open in Overleaf` link on the sidebar and the latex source code will open up in overleaf. The `Open in Overleaf` link is not shown for papers where the authors haven't uploaded the latex source. 18 | 19 | image 20 | 21 | ## How it works 22 | 1. Arxiv provides a latex source for each paper in a `.tar.gz` format 23 | 2. Overleaf provides an [API endpoint](https://www.overleaf.com/devs) to open a latex project with a direct link to a zip file 24 | 3. Our extension converts the `.tar.gz` file from arxiv to a zip file using a backend service hosted on huggingface spaces [here](https://huggingface.co/spaces/amitness/open-in-overleaf) 25 | 4. We then redirect the user to the overleaf page with that url 26 | -------------------------------------------------------------------------------- /scripts/inject.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var BACKEND_URL = 'https://amitness-open-in-overleaf.hf.space' 4 | 5 | function convertToZip() { 6 | // Blur the page to show that conversion is in progress 7 | var overleafTextElement = document.getElementById("overleaf-text"); 8 | var arxivHeader = document.getElementById("header"); 9 | overleafTextElement.textContent = "Converting..."; 10 | document.body.style.filter = 'blur(2px)'; 11 | arxivHeader.style.background = "#4f9c45"; 12 | 13 | // Perform an API call to convert the .tar.gz file to a zip file 14 | fetch(BACKEND_URL + "/run/predict", { 15 | method: "POST", 16 | headers: { "Content-Type": "application/json" }, 17 | body: JSON.stringify({ 18 | data: [ 19 | document.location.href 20 | ] 21 | }) 22 | }) 23 | .then(r => { 24 | if (!r.ok) { 25 | throw new Error('Network response was not ok'); 26 | } 27 | return r.json(); 28 | }) 29 | .then( 30 | r => { 31 | var zip_name = r.data[0]['zip_url']; 32 | var latex_zip_url = BACKEND_URL + "/file=" + zip_name; 33 | 34 | // Redirect to overleaf pointing to the zip file 35 | window.location = "https://www.overleaf.com/docs?snip_uri=" + latex_zip_url; 36 | } 37 | ) 38 | .catch(error => { 39 | setTimeout(() => { 40 | overleafTextElement.textContent = "Open in Overleaf"; 41 | }, 3000); 42 | overleafTextElement.textContent = "Failed. Please try again in few minutes..."; 43 | document.body.style.filter = 'none'; 44 | arxivHeader.style.background = "#b31b1b"; 45 | }); 46 | } 47 | 48 | 49 | function addOverleafButton() { 50 | var otherFormats = document.getElementsByClassName("abs-button download-pdf")[0]; 51 | var ul = otherFormats.parentElement.parentElement; 52 | 53 | // Create a clickable link 54 | var li = document.createElement("li"); 55 | var a = document.createElement('a'); 56 | var linkText = document.createTextNode("Open in Overleaf"); 57 | a.appendChild(linkText); 58 | a.href = "#"; 59 | a.setAttribute("id", "overleaf-text"); 60 | 61 | li.appendChild(a); 62 | li.addEventListener("click", convertToZip); 63 | ul.appendChild(li); 64 | } 65 | 66 | 67 | 68 | addOverleafButton() 69 | --------------------------------------------------------------------------------