commit 62a680bcd252d647f56d6dbe0f1ff1f3b1232800
Author: Alex Balgavy <a.balgavy@gmail.com>
Date: Sun, 11 Oct 2020 15:21:49 +0200
Initial commit
Diffstat:
4 files changed, 57 insertions(+), 0 deletions(-)
diff --git a/README.md b/README.md
@@ -0,0 +1,15 @@
+# Anotools: Chrome/Brave extension to annotate websites using Outline.com and Hypothes.is
+Adds two context menu items to open the page using Outline.com (via [Outline.com](https://outline.com)) or Hypothes.is (via [via.hypothes.is](https://via.hypothes.is)).
+<a target="_blank" href="https://icons8.com/icons/set/pencil">Pencil icon</a> icon by <a target="_blank" href="https://icons8.com">Icons8</a>
+
+Installation:
+1. Download and unzip the [latest release](https://github.com/thezeroalpha/anotools-chrome/releases/latest)
+2. Rename the unzipped directory to `anotools`
+ - When you update manually, replace the **content** of the `anotools` folder with the **content** of the latest zip file
+ - As long as the extension loads from the same path (the `anotools` folder), it will run properly
+3. Go to [chrome://extensions](chrome://extensions)
+4. Enable the _Developer mode_ switch in the top right corner
+5. Click _Load unpacked_ on the left side
+6. In the opened dialog, select the `anotools` folder and click open.
+
+Remember that you need to update manually, by following the directions outlined in step 2 above.
diff --git a/background.js b/background.js
@@ -0,0 +1,29 @@
+chrome.runtime.onInstalled.addListener(function() {
+ var parentMenu = chrome.contextMenus.create({"title": "Anotools", "id": "anotools", "visible": false});
+ chrome.contextMenus.create({"title": "Outline.com", "id": "outline", "parentId": parent.id})
+ chrome.contextMenus.create({"title": "Hypothes.is", "id": "hypothesis", "parentId": parent.id})
+});
+
+chrome.contextMenus.onClicked.addListener(function handleContextMenuClick(info, tab) {
+ function sanitize(url) {
+ return url.replace(/&/g, '&').replace(/</g, '<').replace(/"/g, '"');
+ }
+
+ function outline(tab) {
+ var newUrl = "https://outline.com/"+sanitize(tab.url);
+ chrome.tabs.update(tab.id, {url: newUrl});
+ }
+
+ function hypothesis(tab) {
+ var newUrl = "https://via.hypothes.is/"+sanitize(tab.url);
+ chrome.tabs.update(tab.id, {url: newUrl});
+ }
+
+ var clickedId = info.menuItemId;
+ if (clickedId == "outline") {
+ outline(tab);
+ }
+ else {
+ hypothesis(tab);
+ }
+});
diff --git a/icons8-pencil-48.png b/icons8-pencil-48.png
Binary files differ.
diff --git a/manifest.json b/manifest.json
@@ -0,0 +1,13 @@
+{
+ "name": "Anotools",
+ "version": "1.0",
+ "description": "Open the page in Hypothes.is or Outline.com",
+ "permissions": ["contextMenus", "activeTab"],
+ "icons": {"128": "icons8-pencil-48.png"},
+ "background": {
+ "scripts": ["background.js"],
+ "persistent": false
+ },
+ "browser_action": {"default_icon": "icons8-pencil-48.png"},
+ "manifest_version": 2
+}