Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow hiding badge counter #230

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ The list of available options:
| --------------------------------------------------------------- | ------------------------------------------------------------- |
| Automatically submit forms after filling (aka `autoSubmit`) | Make Browserpass automatically submit the login form for you |
| Enable support for OTP tokens (aka `enableOTP`) | Generate TOTP codes if a TOTP seed is found in the pass entry |
| Hide badge counter on the toolbar icon (aka `hideBadge`) | Do not show badge with number of matching password entries |
| Default username (aka `username`) | Username to use when it's not defined in the password file |
| Custom gpg binary (aka `gpgPath`) | Path to a custom `gpg` binary to use |
| Custom store locations | List of password stores to use |
Expand All @@ -242,6 +243,7 @@ Browserpass allows configuring certain settings in different places places using
- `autoSubmit`
1. Options defined in `.browserpass.json` file located in the root of a password store:
- `autoSubmit`
- `hideBadge`
- `enableOTP`
- `gpgPath`
- `username`
Expand All @@ -251,6 +253,7 @@ Browserpass allows configuring certain settings in different places places using
1. Options defined in browser extension options:
- Automatically submit forms after filling (aka `autoSubmit`)
- Enable support for OTP tokens (aka `enableOTP`)
- Hide badge counter on the toolbar icon (aka `hideBadge`)
- Default username (aka `username`)
- Custom gpg binary (aka `gpgPath`)
- Custom store locations
Expand Down
17 changes: 13 additions & 4 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var defaultSettings = {
username: null,
theme: "auto",
enableOTP: false,
hideBadge: false,
caps: {
save: false,
delete: false,
Expand Down Expand Up @@ -120,15 +121,19 @@ async function updateMatchingPasswordsCount(tabId, forceRefresh = false) {
if (forceRefresh || Date.now() > badgeCache.expires) {
badgeCache.isRefreshing = true;

let files = [];
let settings = await getFullSettings();
let response = await hostAction(settings, "list");
if (response.status != "ok") {
throw new Error(JSON.stringify(response));
if (!settings.hideBadge) {
let response = await hostAction(settings, "list");
if (response.status != "ok") {
throw new Error(JSON.stringify(response));
}
files = response.data.files;
}

const CACHE_TTL_MS = 60 * 1000;
badgeCache = {
files: response.data.files,
files: files,
settings: settings,
expires: Date.now() + CACHE_TTL_MS,
isRefreshing: false,
Expand Down Expand Up @@ -156,6 +161,7 @@ async function updateMatchingPasswordsCount(tabId, forceRefresh = false) {
tabId: tabId,
});
} catch (e) {
badgeCache.isRefreshing = false;
console.log(e);
}
}
Expand Down Expand Up @@ -1146,6 +1152,9 @@ async function saveSettings(settings) {
localStorage.setItem(key, JSON.stringify(settingsToSave[key]));
}
}

// refresh in case user has just toggled showing badge counter
updateMatchingPasswordsCount(settings.tab.id, true);
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/options/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function view(ctl, params) {
nodes.push(
createCheckbox.call(this, "enableOTP", "Enable support for OTP tokens (not recommended)")
);
nodes.push(createCheckbox.call(this, "hideBadge", "Hide badge counter on the toolbar icon"));
nodes.push(createInput.call(this, "username", "Default username", "john.smith"));
nodes.push(createInput.call(this, "gpgPath", "Custom gpg binary", "/path/to/gpg"));

Expand Down