diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7d1a31a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/web-ext-artifacts +uuid diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..92c5f22 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 quaintdev + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..06771a5 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# Snippet Box Sidebar +This extension adds a [Snippet Box](https://github.com/pawelmalak/snippet-box) sidebar to your Firefox as shown in screenshot below. This allows easy saving of code snippets to your self hosted instance. Once installed your instance url must be configured in preferences of extension for it to work properly. + +Your feedback is highly appreciated. + +![](./screenshot.png) diff --git a/icons/code-braces-box.png b/icons/code-braces-box.png new file mode 100644 index 0000000..a282ac5 Binary files /dev/null and b/icons/code-braces-box.png differ diff --git a/internal/background.js b/internal/background.js new file mode 100644 index 0000000..bb523a7 --- /dev/null +++ b/internal/background.js @@ -0,0 +1,5 @@ +browser.browserAction.onClicked.addListener(openPage); +function openPage() { + browser.sidebarAction.open(); +} + diff --git a/internal/options.html b/internal/options.html new file mode 100644 index 0000000..69c04cb --- /dev/null +++ b/internal/options.html @@ -0,0 +1,20 @@ + + + + + + + + + + +
+ + +
+ + + + + + \ No newline at end of file diff --git a/internal/options.js b/internal/options.js new file mode 100644 index 0000000..eeb31b5 --- /dev/null +++ b/internal/options.js @@ -0,0 +1,23 @@ +function saveOptions(e) { + e.preventDefault(); + browser.storage.sync.set({ + url: document.querySelector("#instance-url").value + }); +} + +function restoreOptions() { + + function setCurrentChoice(result) { + document.querySelector("#instance-url").value = result.url; + } + + function onError(error) { + console.log(`Error: ${error}`); + } + + let getting = browser.storage.sync.get("url"); + getting.then(setCurrentChoice, onError); +} + +document.addEventListener("DOMContentLoaded", restoreOptions); +document.querySelector("form").addEventListener("submit", saveOptions); diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..a8ae04e --- /dev/null +++ b/manifest.json @@ -0,0 +1,38 @@ +{ + "manifest_version": 2, + "name": "snippet-box", + "description": "Save snippets from sidebar to your selfhosted snippet-box instance", + "version": "0.3", + "browser_specific_settings": { + "gecko": { + "strict_min_version": "54.0a1" + } + }, + "sidebar_action": { + "default_icon": "icons/code-braces-box.png", + "default_title": "snippet-box", + "default_panel": "sidebar/panel.html" + }, + "browser_action": { + "default_icon": "icons/code-braces-box.png" + }, + "background": { + "scripts": [ + "internal/background.js" + ] + }, + "options_ui": { + "page": "internal/options.html" + }, + "permissions": [ + "storage", + "" + ], + "commands": { + "_execute_sidebar_action": { + "suggested_key": { + "default": "Ctrl+Shift+Y" + } + } + } +} \ No newline at end of file diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..ee92f1b Binary files /dev/null and b/screenshot.png differ diff --git a/sidebar/panel.html b/sidebar/panel.html new file mode 100644 index 0000000..4f639de --- /dev/null +++ b/sidebar/panel.html @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/sidebar/panel.js b/sidebar/panel.js new file mode 100644 index 0000000..e46140d --- /dev/null +++ b/sidebar/panel.js @@ -0,0 +1,11 @@ + +window.addEventListener('load', (event) => { + browser.storage.sync.get("url").then((item) => { + console.log(item) + browser.sidebarAction.setPanel({ panel: browser.runtime.getURL(item.url) }); + }, (error) => { + console.log(error) + }); +}); + +