-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize dark theme, fill out form using browser action icon popup
- Loading branch information
Showing
10 changed files
with
111 additions
and
112 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 |
---|---|---|
|
@@ -4,6 +4,8 @@ Integrates sysPass password manager in Firefox | |
|
||
Addon page: https://addons.mozilla.org/de/firefox/addon/syspass/ | ||
|
||
Works with Firefox, Chrome and Edge Chromium | ||
|
||
![syspass firefox integration](preview.gif "Logo Title Text 1") | ||
|
||
## Configuration | ||
|
@@ -23,10 +25,18 @@ Clone repository: | |
|
||
``` | ||
git clone [email protected]:ochorocho/syspass-firefox.git | ||
cd syspass-firefox | ||
yarn install | ||
``` | ||
|
||
To use [web-ext](https://www.npmjs.com/package/web-ext) to run an instance of Firefox with the addon enabled run the following within the pugins directory: | ||
|
||
``` | ||
web-ext run | ||
yarn dev | ||
``` | ||
|
||
Package addon: | ||
|
||
``` | ||
yarn build | ||
``` |
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 |
---|---|---|
|
@@ -9,7 +9,8 @@ | |
}, | ||
"permissions": [ | ||
"storage", | ||
"*://*/*" | ||
"*://*/*", | ||
"tabs" | ||
], | ||
"options_ui": { | ||
"page": "options.html" | ||
|
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
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
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 |
---|---|---|
@@ -1,100 +1,49 @@ | ||
import "../scss/popup.scss" | ||
|
||
/** | ||
* CSS to hide everything on the page, | ||
* except for elements that have the "beastify-image" class. | ||
*/ | ||
const hidePage = `body > :not(.beastify-image) { | ||
display: none; | ||
}`; | ||
const gettingStoredSettings = browser.storage.local.get(); | ||
let settings; | ||
const currentTab = browser.tabs.query({currentWindow: true, active: true}) | ||
|
||
/** | ||
* Listen for clicks on the buttons, and send the appropriate message to | ||
* the content script in the page. | ||
* Get addon settings | ||
*/ | ||
function listenForClicks() { | ||
document.addEventListener("click", (e) => { | ||
|
||
/** | ||
* Given the name of a beast, get the URL to the corresponding image. | ||
*/ | ||
function beastNameToURL(beastName) { | ||
switch (beastName) { | ||
case "Frog": | ||
return browser.extension.getURL("beasts/frog.jpg"); | ||
case "Snake": | ||
return browser.extension.getURL("beasts/snake.jpg"); | ||
case "Turtle": | ||
return browser.extension.getURL("beasts/turtle.jpg"); | ||
} | ||
} | ||
gettingStoredSettings.then(function (data) { | ||
let settingsSearch = Object.assign({ "method": 'account/search' }, data); | ||
settings = data; | ||
|
||
/** | ||
* Insert the page-hiding CSS into the active tab, | ||
* then get the beast URL and | ||
* send a "beastify" message to the content script in the active tab. | ||
*/ | ||
function beastify(tabs) { | ||
browser.tabs.insertCSS({code: hidePage}).then(() => { | ||
let url = beastNameToURL(e.target.textContent); | ||
browser.tabs.sendMessage(tabs[0].id, { | ||
command: "beastify", | ||
beastURL: url | ||
}); | ||
currentTab.then((tabs) => { | ||
let url = new URL(tabs[0].url); | ||
chrome.runtime.sendMessage({contentScriptQuery: "accountSearch", text: url.hostname, settings: settingsSearch}, data => createList(data)); | ||
}); | ||
} | ||
}); | ||
|
||
/** | ||
* Remove the page-hiding CSS from the active tab, | ||
* send a "reset" message to the content script in the active tab. | ||
*/ | ||
function reset(tabs) { | ||
browser.tabs.removeCSS({code: hidePage}).then(() => { | ||
|
||
|
||
/** | ||
* Transform results into a autocompleter readable format | ||
* | ||
* @param data | ||
* @returns {[]} | ||
*/ | ||
function createList(data) { | ||
let popUpList = document.querySelector("#popup-list"); | ||
popUpList.innerHTML = ''; | ||
|
||
data.result.result.forEach(function (item) { | ||
let link = document.createElement('div'); | ||
link.setAttribute('data-login', item.login); | ||
link.innerText = item.name; | ||
link.className = "popup-list__item"; | ||
link.addEventListener('click', function (e) { | ||
currentTab.then((tabs) => { | ||
browser.tabs.sendMessage(tabs[0].id, { | ||
command: "reset", | ||
command: "fillOutForm", | ||
login: item.login, | ||
id: item.id, | ||
}); | ||
}); | ||
} | ||
}) | ||
|
||
/** | ||
* Just log the error to the console. | ||
*/ | ||
function reportError(error) { | ||
console.error(`Could not beastify: ${error}`); | ||
} | ||
|
||
/** | ||
* Get the active tab, | ||
* then call "beastify()" or "reset()" as appropriate. | ||
*/ | ||
if (e.target.classList.contains("beast")) { | ||
browser.tabs.query({active: true, currentWindow: true}) | ||
.then(beastify) | ||
.catch(reportError); | ||
} | ||
else if (e.target.classList.contains("reset")) { | ||
browser.tabs.query({active: true, currentWindow: true}) | ||
.then(reset) | ||
.catch(reportError); | ||
} | ||
popUpList.appendChild(link); | ||
}); | ||
} | ||
|
||
/** | ||
* There was an error executing the script. | ||
* Display the popup's error message, and hide the normal UI. | ||
*/ | ||
function reportExecuteScriptError(error) { | ||
document.querySelector("#popup-content").classList.add("hidden"); | ||
document.querySelector("#error-content").classList.remove("hidden"); | ||
console.error(`Failed to execute beastify content script: ${error.message}`); | ||
} | ||
|
||
/** | ||
* When the popup loads, inject a content script into the active tab, | ||
* and add a click handler. | ||
* If we couldn't inject the script, handle the error. | ||
*/ | ||
browser.tabs.executeScript({file: "/content_scripts/beastify.js"}) | ||
.then(listenForClicks) | ||
.catch(reportExecuteScriptError); |
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
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
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
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
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 |
---|---|---|
|
@@ -35,5 +35,5 @@ | |
} | ||
|
||
.syspass-spinner { | ||
@include spinner($success, $error); | ||
@include spinner; | ||
} |