Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
quaintdev committed Dec 11, 2021
0 parents commit b518990
Show file tree
Hide file tree
Showing 11 changed files with 139 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/web-ext-artifacts
uuid
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Binary file added icons/code-braces-box.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions internal/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
browser.browserAction.onClicked.addListener(openPage);
function openPage() {
browser.sidebarAction.open();
}

20 changes: 20 additions & 0 deletions internal/options.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>

<html>

<head>
<meta charset="utf-8">
</head>

<body>

<form>
<label>Snippet Box Instance Url<input type="text" id="instance-url"></label>
<button type="submit">Save</button>
</form>

<script src="options.js"></script>

</body>

</html>
23 changes: 23 additions & 0 deletions internal/options.js
Original file line number Diff line number Diff line change
@@ -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);
38 changes: 38 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -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",
"<all_urls>"
],
"commands": {
"_execute_sidebar_action": {
"suggested_key": {
"default": "Ctrl+Shift+Y"
}
}
}
}
Binary file added screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions sidebar/panel.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<script src="panel.js"></script>
</head>

<body>

</body>

</html>
11 changes: 11 additions & 0 deletions sidebar/panel.js
Original file line number Diff line number Diff line change
@@ -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)
});
});


0 comments on commit b518990

Please sign in to comment.