Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc-browser.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvarjolintu <sami.vanttinen@protonmail.com>2020-02-06 21:42:32 +0300
committervarjolintu <sami.vanttinen@protonmail.com>2020-02-06 22:05:51 +0300
commit5ea08adac8a93ae3a9f8ddb823984b29cdcbe53e (patch)
treeaea863e64031b4810ac0bd17f8b5d94ab77a4615 /keepassxc-browser/background
parentb01ab1e8352d16ef7ea17faca1bdb05d6c856c2a (diff)
Redirect allowance
Diffstat (limited to 'keepassxc-browser/background')
-rwxr-xr-xkeepassxc-browser/background/event.js5
-rw-r--r--keepassxc-browser/background/init.js16
-rwxr-xr-xkeepassxc-browser/background/page.js91
3 files changed, 75 insertions, 37 deletions
diff --git a/keepassxc-browser/background/event.js b/keepassxc-browser/background/event.js
index aa7cb83..393aa33 100755
--- a/keepassxc-browser/background/event.js
+++ b/keepassxc-browser/background/event.js
@@ -241,6 +241,10 @@ kpxcEvent.getColorTheme = async function(tab) {
return page.settings.colorTheme;
};
+kpxcEvent.pageGetRedirectCount = async function() {
+ return page.redirectCount;
+};
+
// All methods named in this object have to be declared BEFORE this!
kpxcEvent.messageHandlers = {
'add_credentials': keepass.addCredentials,
@@ -266,6 +270,7 @@ kpxcEvent.messageHandlers = {
'page_clear_logins': kpxcEvent.pageClearLogins,
'page_clear_submitted': kpxcEvent.pageClearSubmitted,
'page_get_login_id': kpxcEvent.pageGetLoginId,
+ 'page_get_redirect_count': kpxcEvent.pageGetRedirectCount,
'page_get_submitted': kpxcEvent.pageGetSubmitted,
'page_set_login_id': kpxcEvent.pageSetLoginId,
'page_set_submitted': kpxcEvent.pageSetSubmitted,
diff --git a/keepassxc-browser/background/init.js b/keepassxc-browser/background/init.js
index 14202f6..fec0ccb 100644
--- a/keepassxc-browser/background/init.js
+++ b/keepassxc-browser/background/init.js
@@ -71,6 +71,7 @@ browser.tabs.onActivated.addListener(async function(activeInfo) {
* Update browserAction on every update of the page
* @param {integer} tabId
* @param {object} changeInfo
+ * @param {object} tab
*/
browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
// If the tab URL has changed (e.g. logged in) clear credentials
@@ -86,6 +87,21 @@ browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
}
});
+/**
+ * Detects page redirects and increases the count. Count is reset after a normal navigation event.
+ * Form submit is counted as one.
+ * @param {object} details
+ */
+browser.webNavigation.onCommitted.addListener((details) => {
+ if ((details.transitionQualifiers.length > 0 && details.transitionQualifiers[0] === 'client_redirect') ||
+ details.transitionType === 'form_submit') {
+ page.redirectCount += 1;
+ return;
+ }
+
+ page.redirectCount = 0;
+});
+
browser.runtime.onMessage.addListener(kpxcEvent.onMessage);
const contextMenuItems = [
diff --git a/keepassxc-browser/background/page.js b/keepassxc-browser/background/page.js
index 6a22327..c87ca68 100755
--- a/keepassxc-browser/background/page.js
+++ b/keepassxc-browser/background/page.js
@@ -1,23 +1,23 @@
'use strict';
const defaultSettings = {
- checkUpdateKeePassXC: 3,
autoCompleteUsernames: true,
autoFillAndSend: false,
- usePasswordGeneratorIcons: false,
autoFillSingleEntry: false,
- autoSubmit: false,
- autoRetrieveCredentials: true,
- showNotifications: true,
- showLoginNotifications: true,
- showLoginFormIcon: true,
- showOTPIcon: true,
- saveDomainOnly: true,
- saveDomainOnlyNewCreds: false,
autoReconnect: false,
+ autoRetrieveCredentials: true,
+ autoSubmit: false,
+ checkUpdateKeePassXC: 3,
+ colorTheme: 'system',
defaultGroup: '',
defaultGroupAlwaysAsk: false,
- colorTheme: 'system'
+ redirectAllowance: 1,
+ saveDomainOnly: true,
+ showLoginFormIcon: true,
+ showLoginNotifications: true,
+ showNotifications: true,
+ showOTPIcon: true,
+ usePasswordGeneratorIcons: false
};
var page = {};
@@ -25,6 +25,7 @@ page.blockedTabs = [];
page.currentTabId = -1;
page.loginId = -1;
page.passwordFilled = false;
+page.redirectCount = 0;
page.submitted = false;
page.submittedCredentials = {};
page.tabs = [];
@@ -35,56 +36,72 @@ page.initSettings = async function() {
const item = await browser.storage.local.get({ 'settings': {} });
page.settings = item.settings;
- if (!('checkUpdateKeePassXC' in page.settings)) {
- page.settings.checkUpdateKeePassXC = defaultSettings.checkUpdateKeePassXC;
- }
if (!('autoCompleteUsernames' in page.settings)) {
page.settings.autoCompleteUsernames = defaultSettings.autoCompleteUsernames;
}
+
if (!('autoFillAndSend' in page.settings)) {
page.settings.autoFillAndSend = defaultSettings.autoFillAndSend;
}
- if (!('usePasswordGeneratorIcons' in page.settings)) {
- page.settings.usePasswordGeneratorIcons = defaultSettings.usePasswordGeneratorIcons;
- }
+
if (!('autoFillSingleEntry' in page.settings)) {
page.settings.autoFillSingleEntry = defaultSettings.autoFillSingleEntry;
}
- if (!('autoSubmit' in page.settings)) {
- page.settings.autoSubmit = defaultSettings.autoSubmit;
+
+ if (!('autoReconnect' in page.settings)) {
+ page.settings.autoReconnect = defaultSettings.autoReconnect;
}
+
if (!('autoRetrieveCredentials' in page.settings)) {
page.settings.autoRetrieveCredentials = defaultSettings.autoRetrieveCredentials;
}
- if (!('showNotifications' in page.settings)) {
- page.settings.showNotifications = defaultSettings.showNotifications;
+
+ if (!('autoSubmit' in page.settings)) {
+ page.settings.autoSubmit = defaultSettings.autoSubmit;
}
- if (!('showLoginNotifications' in page.settings)) {
- page.settings.showLoginNotifications = defaultSettings.showLoginNotifications;
+
+ if (!('checkUpdateKeePassXC' in page.settings)) {
+ page.settings.checkUpdateKeePassXC = defaultSettings.checkUpdateKeePassXC;
}
- if (!('showLoginFormIcon' in page.settings)) {
- page.settings.showLoginFormIcon = defaultSettings.showLoginFormIcon;
+
+ if (!('colorTheme' in page.settings)) {
+ page.settings.colorTheme = defaultSettings.colorTheme;
}
- if (!('showOTPIcon' in page.settings)) {
- page.settings.showOTPIcon = defaultSettings.showOTPIcon;
+
+ if (!('defaultGroup' in page.settings)) {
+ page.settings.defaultGroup = defaultSettings.defaultGroup;
}
+
+ if (!('defaultGroupAlwaysAsk' in page.settings)) {
+ page.settings.defaultGroupAlwaysAsk = defaultSettings.defaultGroupAlwaysAsk;
+ }
+
if (!('saveDomainOnly' in page.settings)) {
page.settings.saveDomainOnly = defaultSettings.saveDomainOnly;
}
- if (!('saveDomainOnlyNewCreds' in page.settings)) {
- page.settings.saveDomainOnlyNewCreds = defaultSettings.saveDomainOnlyNewCreds;
+
+ if (!('showLoginFormIcon' in page.settings)) {
+ page.settings.showLoginFormIcon = defaultSettings.showLoginFormIcon;
}
- if (!('autoReconnect' in page.settings)) {
- page.settings.autoReconnect = defaultSettings.autoReconnect;
+
+ if (!('showLoginNotifications' in page.settings)) {
+ page.settings.showLoginNotifications = defaultSettings.showLoginNotifications;
}
- if (!('defaultGroup' in page.settings)) {
- page.settings.defaultGroup = defaultSettings.defaultGroup;
+
+ if (!('showNotifications' in page.settings)) {
+ page.settings.showNotifications = defaultSettings.showNotifications;
}
- if (!('defaultGroupAlwaysAsk' in page.settings)) {
- page.settings.defaultGroupAlwaysAsk = defaultSettings.defaultGroupAlwaysAsk;
+
+ if (!('showOTPIcon' in page.settings)) {
+ page.settings.showOTPIcon = defaultSettings.showOTPIcon;
}
- if (!('colorTheme' in page.settings)) {
- page.settings.colorTheme = defaultSettings.colorTheme;
+
+ if (!('usePasswordGeneratorIcons' in page.settings)) {
+ page.settings.usePasswordGeneratorIcons = defaultSettings.usePasswordGeneratorIcons;
+ }
+
+ if (!('redirectAllowance' in page.settings)) {
+ page.settings.redirectAllowance = defaultSettings.redirectAllowance;
}
await browser.storage.local.set({ 'settings': page.settings });