diff --git a/README.md b/README.md new file mode 100644 index 0000000..387e6d0 --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# ePDF Downloader + +ePDF Downloader is a simple Chrome extension that adds a floating download button to webpages containing links containing `/doi/reader/` or `/doi/epdf/`. + +![screenshot](image.png) + +## Installation +1. Download the extension ZIP file from the GitHub repository. +2. Unzip the downloaded file. +3. Open Google Chrome and go to [chrome://extensions/](chrome://extensions/). +4. Turn on "Developer mode" (top right corner). +5. Click "Load unpacked" and select the unzipped folder. +6. ePDF Downloader will be added to your Chrome browser. + +## Usage +1. Visit a webpage that has paper links with either `/doi/reader/` or `doi/epdf/`. +2. Look for the floating download button in the bottom right corner. +3. If a DOI link with the specified pattern is detected, the button will appear. +4. Click the button to open a new tab and download the PDF. + +## Uninstalling +1. Go to [chrome://extensions/](chrome://extensions/). +2. Find "ePDF Downloader" in the list. +3. Click "Remove" to uninstall the extension. + +## Contributing +Contributions are welcome! Feel free to open an issue or create a pull request on GitHub. + +## License +ePDF Downloader is licensed under the MIT License. + +Thank you for using ePDF Downloader! If you have any questions or need support, please let us know in the Issues section. Enjoy easy PDF downloads! \ No newline at end of file diff --git a/content.js b/content.js new file mode 100644 index 0000000..fc90a15 --- /dev/null +++ b/content.js @@ -0,0 +1,47 @@ +scanHTMLForDOIUrls(); + +function scanHTMLForDOIUrls() { + const docLinks = document.links; + for (let i = 0; i < docLinks.length; i++) { + const link = docLinks[i].href; + if (link.includes("/doi/reader/") || link.includes("/doi/epdf/")) { + addDownloadButton(link); + } + } +} + +function addDownloadButton(url) { + const newUrl = getUpdatedURL(url); + if (newUrl) { + const button = document.createElement("button"); + button.style.position = "fixed"; + button.style.bottom = "20px"; + button.style.right = "20px"; + button.style.backgroundColor = "transparent"; + button.style.border = "none"; + button.style.zIndex = "9999"; + + const iconImage = new Image(); + iconImage.src = chrome.runtime.getURL('pdf.svg'); + iconImage.style.width = "auto"; + iconImage.style.height = "60px"; + iconImage.style.objectFit = "contain"; + + button.appendChild(iconImage); + + button.addEventListener("click", function () { + window.open(newUrl, "_blank"); + }); + + document.body.appendChild(button); + } +} + +function getUpdatedURL(url) { + if (url.includes("/doi/reader/")) { + return url.replace("/doi/reader/", "/doi/pdf/"); + } else if (url.includes("/doi/epdf/")) { + return url.replace("/doi/epdf/", "/doi/pdf/"); + } + return null; +} diff --git a/download-icon.png b/download-icon.png new file mode 100644 index 0000000..0f12ae5 Binary files /dev/null and b/download-icon.png differ diff --git a/epdf-downloader.zip b/epdf-downloader.zip new file mode 100644 index 0000000..cdd44c4 Binary files /dev/null and b/epdf-downloader.zip differ diff --git a/image.png b/image.png new file mode 100644 index 0000000..cd8f344 Binary files /dev/null and b/image.png differ diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..58452d6 --- /dev/null +++ b/manifest.json @@ -0,0 +1,22 @@ +{ + "manifest_version": 3, + "name": "ePDF Downloader", + "version": "1.0", + "description": "A Chrome extension to download PDF from ePDF links", + "permissions": ["activeTab"], + "content_scripts": [ + { + "matches": ["https://*/*", "http://*/*"], + "js": ["content.js"] + } + ], + "web_accessible_resources": [ + { + "resources": ["pdf.svg"], + "matches": ["https://*/*", "http://*/*"] + } + ], + "icons": { + "48": "download-icon.png" + } +} diff --git a/pdf.svg b/pdf.svg new file mode 100644 index 0000000..2e5b105 --- /dev/null +++ b/pdf.svg @@ -0,0 +1,19 @@ + + + + + + + + + \ No newline at end of file