-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c52d077
Showing
7 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |