diff --git a/README.md b/README.md new file mode 100644 index 0000000..5cd40b1 --- /dev/null +++ b/README.md @@ -0,0 +1,25 @@ +# SimplyPapers Browser Extension (mainly Chrome) +WebExtension API based browser extension to simply access papers via our LMU/TUM institutional accounts. + +Click the Extension icon and select through which institution you want to access the paper you're currently viewing (e.g. on ACM, IEE, ...). The extension will redirect to the paper through the institutional login. Actually logging in is only necessary the first time. (until you delete your cookies ;) + +> The extension does NOT log you in, it merely redirects. I.e. your passwords are not read by the extension. + +## Example Usage +![gif of useage](doc/paperAccessPreview.gif) + +## Setup +1. Download the current release from the github releases page of this repo and unzip it. Or simply clone the repo. +2. Install it + + __For Chome:__ follow [this guide](https://ui.vision/howto/install-chrome-extension-from-file) to install the extension via `load unpacked` + + __For Firefox:__ Sadly you can't install local extensions permanently without [some hassle](https://stackoverflow.com/questions/62237202/firefox-add-ons-how-to-install-my-own-local-add-on-extension-permanently-in-f). To install it temporarily (i.e. until you close Firefoy again): + + - got to `about:debugging#/runtime/this-firefox` + - `load temporary add-on` + - Select the `manifest.json` in this repo +3. Happy paper accessing ;) + +## Roadmap +Currently the urls for lmu and tum are hardcoded. It would be nice to make them user configurable -> i.e. add a dialog to add new ones and dynamically generate the buttons in the popup from these. But we all have to write our thesis, I guess... \ No newline at end of file diff --git a/doc/paperAccessPreview.gif b/doc/paperAccessPreview.gif new file mode 100644 index 0000000..8dbb915 Binary files /dev/null and b/doc/paperAccessPreview.gif differ diff --git a/images/logo_1024.png b/images/logo_1024.png new file mode 100644 index 0000000..aaca550 Binary files /dev/null and b/images/logo_1024.png differ diff --git a/images/logo_256.png b/images/logo_256.png new file mode 100644 index 0000000..d23894e Binary files /dev/null and b/images/logo_256.png differ diff --git a/images/logo_48.png b/images/logo_48.png new file mode 100644 index 0000000..90bb484 Binary files /dev/null and b/images/logo_48.png differ diff --git a/images/logo_512.png b/images/logo_512.png new file mode 100644 index 0000000..0593089 Binary files /dev/null and b/images/logo_512.png differ diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..dab287f --- /dev/null +++ b/manifest.json @@ -0,0 +1,34 @@ +{ + "name": "SimplyPapers", + "description": "Access scientific papers via your institution account on any site with a single click.", + "version": "1.0", + "icons": { + "48": "images/logo_48.png", + "256": "images/logo_256.png", + "512": "images/logo_512.png", + "1024": "images/logo_1024.png" + }, + "manifest_version": 3, + "content_scripts": [ + { + "matches": [ + "*://*/*" + ], + "css": [], + "js": [ + "scripts/content.js" + ] + } + ], + "permissions": [ + "activeTab", + "scripting" + ], + "action": { + "default_icon": { + "16": "images/logo_48.png" + }, + "default_title": "SimplyPapers", + "default_popup": "popup.html" + } +} \ No newline at end of file diff --git a/popup.html b/popup.html new file mode 100644 index 0000000..5c96652 --- /dev/null +++ b/popup.html @@ -0,0 +1,54 @@ + + + + + + + Document + + + +
+ +
+ +
+ + + + \ No newline at end of file diff --git a/scripts/content.js b/scripts/content.js new file mode 100644 index 0000000..29d8470 --- /dev/null +++ b/scripts/content.js @@ -0,0 +1,28 @@ +/** + * Replace the currently active url xay.abc.com/... with a version xay-abc-com./... + * And navigate to that new url. + * + * The is provided by the message request + */ +chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) { + let currentLocation = document.location; + + //ensure idempotence + if (!currentLocation.hostname.includes(request.accessUrl)) { + let newURL = currentLocation.protocol + "//"; + + let paperAccessHostName = currentLocation.hostname.replaceAll('.', '-') + "." + request.accessUrl; + + newURL += paperAccessHostName + (currentLocation.port.length > 0 ? ":" + currentLocation.port : "") + currentLocation.pathname + currentLocation.search + currentLocation.hash; + + console.log("Redirect to: " + newURL); + + document.location.assign(newURL); + } else { + //we already are on a "accessified" page, do nothing :) + } + + sendResponse({ success: true }); +}); + +console.log("Registered Paper Access Extension"); \ No newline at end of file diff --git a/scripts/popup.js b/scripts/popup.js new file mode 100644 index 0000000..37c850e --- /dev/null +++ b/scripts/popup.js @@ -0,0 +1,13 @@ +const TUMeaccessUrl = "eaccess.ub.tum.de" +const LMUeaccessUrl = "emedien.ub.uni-muenchen.de" + +function accessPaper(accessUrl) { + chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { + chrome.tabs.sendMessage(tabs[0].id, { accessUrl }, function (response) { + console.log('success'); + }); + }); +} + +document.getElementById('lmu').addEventListener('click', () => accessPaper(LMUeaccessUrl)); +document.getElementById('tum').addEventListener('click', () => accessPaper(TUMeaccessUrl)); \ No newline at end of file