mirror of
https://github.com/keepassxreboot/keepassxc-browser.git
synced 2026-03-11 08:54:43 +00:00
Replace Ignored sites with Site preferences
This commit is contained in:
parent
f359e4af55
commit
e8d8c56449
6 changed files with 126 additions and 83 deletions
|
|
@ -205,10 +205,10 @@ browserAction.setRememberPopup = function(tabId, username, password, url, userna
|
|||
browser.storage.local.get({'settings': {}}).then(function(item) {
|
||||
const settings = item.settings;
|
||||
|
||||
// Don't show anything if the site is in the ignore list
|
||||
if (settings.ignoredSites !== undefined) {
|
||||
for (const site of settings.ignoredSites) {
|
||||
if (siteMatch(site.url, url)) {
|
||||
// Don't show anything if the site is in the ignore
|
||||
if (settings.sitePreferences !== undefined) {
|
||||
for (const site of settings.sitePreferences) {
|
||||
if (site.ignore === IGNORE_NORMAL && (site.url === url || siteMatch(site.url, url))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
const IGNORE_NOTHING = 'ignoreNothing';
|
||||
const IGNORE_NORMAL = 'ignoreNormal';
|
||||
const IGNORE_FULL = 'ignoreFull';
|
||||
|
||||
var isFirefox = function() {
|
||||
if (!(/Chrome/.test(navigator.userAgent) && /Google/.test(navigator.vendor))) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -1424,12 +1424,16 @@ cip.initCredentialFields = function(forceCall) {
|
|||
browser.runtime.sendMessage({ 'action': 'page_clear_logins', args: [_called.clearLogins] }).then(() => {
|
||||
_called.clearLogins = true;
|
||||
|
||||
// Ignore sites with full ignore
|
||||
cip.initializeIgnoredSites();
|
||||
if (cip.settings.ignoredSites) {
|
||||
for (const site of cip.settings.ignoredSites) {
|
||||
if (site.fullIgnore && siteMatch(site.url, document.location.href)) {
|
||||
return;
|
||||
// Check site preferences
|
||||
cip.initializeSitePreferences();
|
||||
if (cip.settings.sitePreferences) {
|
||||
for (const site of cip.settings.sitePreferences) {
|
||||
if (site.url === document.location.href || siteMatch(site.url, document.location.href)) {
|
||||
if (site.ignore === IGNORE_FULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
_singleInputEnabledForPage = site.usernameOnly;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1470,6 +1474,8 @@ cip.initCredentialFields = function(forceCall) {
|
|||
}).then(cip.retrieveCredentialsCallback).catch((e) => {
|
||||
console.log(e);
|
||||
});
|
||||
} else if (_singleInputEnabledForPage) {
|
||||
cip.preparePageForMultipleCredentials(cip.credentials);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
@ -2049,13 +2055,25 @@ cip.ignoreSite = function(sites) {
|
|||
return;
|
||||
}
|
||||
|
||||
cip.initializeIgnoredSites();
|
||||
|
||||
const site = sites[0];
|
||||
cip.settings['ignoredSites'].push({
|
||||
url: site,
|
||||
fullIgnore: false
|
||||
});
|
||||
cip.initializeSitePreferences();
|
||||
|
||||
// Check if the site already exists
|
||||
let siteExists = false;
|
||||
for (const existingSite of cip.settings['sitePreferences']) {
|
||||
if (existingSite.url === site) {
|
||||
existingSite.ignore = IGNORE_NORMAL;
|
||||
siteExists = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!siteExists) {
|
||||
cip.settings['sitePreferences'].push({
|
||||
url: site,
|
||||
ignore: IGNORE_NORMAL,
|
||||
usernameOnly: false
|
||||
});
|
||||
}
|
||||
|
||||
browser.runtime.sendMessage({
|
||||
action: 'save_settings',
|
||||
|
|
@ -2064,13 +2082,13 @@ cip.ignoreSite = function(sites) {
|
|||
};
|
||||
|
||||
// Delete previously created Object if it exists. It will be replaced by an Array
|
||||
cip.initializeIgnoredSites = function() {
|
||||
if (cip.settings['ignoredSites'] !== undefined && cip.settings['ignoredSites'].constructor === Object) {
|
||||
delete cip.settings['ignoredSites'];
|
||||
cip.initializeSitePreferences = function() {
|
||||
if (cip.settings['sitePreferences'] !== undefined && cip.settings['sitePreferences'].constructor === Object) {
|
||||
delete cip.settings['sitePreferences'];
|
||||
}
|
||||
|
||||
if (!cip.settings['ignoredSites']) {
|
||||
cip.settings['ignoredSites'] = [];
|
||||
if (!cip.settings['sitePreferences']) {
|
||||
cip.settings['sitePreferences'] = [];
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ h2+hr {
|
|||
margin-right: 5px;
|
||||
}
|
||||
|
||||
#ignoreUrl {
|
||||
#manualUrl {
|
||||
width: 75%;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,14 +20,14 @@
|
|||
<li class="active"><a href="#general-settings">General</a></li>
|
||||
<li><a href="#connected-databases">Connected Databases</a></li>
|
||||
<li><a href="#custom-fields">Custom credential fields</a></li>
|
||||
<li><a href="#ignored-sites">Ignored sites</a></li>
|
||||
<li><a href="#site-preferences">Site preferences</a></li>
|
||||
<li><a href="#about">About</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<!-- General Settings -->
|
||||
<div class="tab" id="tab-general-settings">
|
||||
<h2>General Settings</h2>
|
||||
<h2>General settings</h2>
|
||||
<hr />
|
||||
<p>
|
||||
If you just want to insert username + password into the fields where your focus is, press <code><span id="mac-user-shortcut">Ctrl + Shift + U</span><span id="default-user-shortcut">Alt + Shift + U</span></code>.
|
||||
|
|
@ -189,7 +189,7 @@
|
|||
|
||||
<!-- Connected Databases -->
|
||||
<div class="tab" id="tab-connected-databases">
|
||||
<h2>Connected Databases</h2>
|
||||
<h2>Connected databases</h2>
|
||||
<hr />
|
||||
<p>
|
||||
The following KeePassXC databases are connected to KeePassXC-Browser.
|
||||
|
|
@ -289,24 +289,26 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Ignored sites -->
|
||||
<div class="tab" id="tab-ignored-sites">
|
||||
<h2>Ignored sites</h2>
|
||||
<!-- Site preferences -->
|
||||
<div class="tab" id="tab-site-preferences">
|
||||
<h2>Site preferences</h2>
|
||||
<hr />
|
||||
<p>
|
||||
Sites in this list are ignored when new credentials are detected.
|
||||
Sites on this page have special handling methods associated with them.
|
||||
<br />
|
||||
Go to the page with new credentials, click the blinking KeePassXC-Browser icon or the notification and select <em>Never ask for this page</em>.
|
||||
To ignore new/modified credentials on a specific site, add it below or click the blinking KeePassXC-Browser icon and select <em>Never ask for this page</em>.
|
||||
<br />
|
||||
If full ignore is enabled, no input fields are detected and no credentials are received for that site.
|
||||
If a site is fully ignored (<em>Disable all features</em> is selected), then the plugin will do nothing when visiting that site.
|
||||
<br />
|
||||
Enabling the <em>Username-Only Detection</em> feature allows KeePassXC-Browser to fill-in pages on sites that do present a separated username and password input.
|
||||
</p>
|
||||
<hr />
|
||||
<div class="form-group">
|
||||
<label for="ignoreManualAdd">Add URL manually:</label>
|
||||
<label for="sitePreferencesManualAdd">Add URL manually:</label>
|
||||
<div class="control-group">
|
||||
<div class="input-append">
|
||||
<input type="url" id="ignoreUrl"/>
|
||||
<button class="btn btn-sm btn-primary" id="ignoreManualAddButton" type="button"><span class="glyphicon glyphicon-plus-sign"></span> Add</button>
|
||||
<input type="url" id="manualUrl"/>
|
||||
<button class="btn btn-sm btn-primary" id="sitePreferencesManualAdd" type="button"><span class="glyphicon glyphicon-plus-sign"></span> Add</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -315,22 +317,30 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th>Page URL</th>
|
||||
<th>Ignore</th>
|
||||
<th>Username-Only Detection</th>
|
||||
<th>Delete</th>
|
||||
<th>Full ignore</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="empty">
|
||||
<td colspan="3">No ignored sites found.</td>
|
||||
<td colspan="4">No sites found.</td>
|
||||
</tr>
|
||||
<tr class="clone">
|
||||
<td></td>
|
||||
<td>
|
||||
<select name="ignore">
|
||||
<option value="ignoreNothing">Enable all features</option>
|
||||
<option value="ignoreNormal">Disable new/modified credentials</option>
|
||||
<option value="ignoreFull">Disable all features</option>
|
||||
</select>
|
||||
</td>
|
||||
<td><input type="checkbox" name="usernameOnly" value="false" /></td>
|
||||
<td><button class="btn delete btn-danger btn"><span class="glyphicon glyphicon-remove-sign"></span> Remove</button></td>
|
||||
<td><input type="checkbox" name="fullIgnore" value="false" /></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div id="dialogDeleteIgnoredSite" class="modal fade" tabindex="-1" role="dialog">
|
||||
<div id="dialogDeleteSite" class="modal fade" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
|
|
@ -338,8 +348,8 @@
|
|||
<h3 id="myModalLabel">Remove site?</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Do you really want to remove the specified site from the ignore list?</p>
|
||||
<p class="help-block">KeePassXC-Browser will detect new credentials the next time you visit this page.</p>
|
||||
<p>Do you really want to remove the specified site from the list?</p>
|
||||
<p class="help-block">KeePassXC-Browser will enable all features for this site and remove username-only detection.</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ $(function() {
|
|||
options.initGeneralSettings();
|
||||
options.initConnectedDatabases();
|
||||
options.initCustomCredentialFields();
|
||||
options.initIgnoredSites();
|
||||
options.initSitePreferences();
|
||||
options.initAbout();
|
||||
});
|
||||
});
|
||||
|
|
@ -261,100 +261,111 @@ options.initCustomCredentialFields = function() {
|
|||
}
|
||||
};
|
||||
|
||||
options.initIgnoredSites = function() {
|
||||
$('#dialogDeleteIgnoredSite').modal({keyboard: true, show: false, backdrop: true});
|
||||
$('#tab-ignored-sites tr.clone:first button.delete:first').click(function(e) {
|
||||
options.initSitePreferences = function() {
|
||||
$('#dialogDeleteSite').modal({keyboard: true, show: false, backdrop: true});
|
||||
$('#tab-site-preferences tr.clone:first button.delete:first').click(function(e) {
|
||||
e.preventDefault();
|
||||
$('#dialogDeleteIgnoredSite').data('url', $(this).closest('tr').data('url'));
|
||||
$('#dialogDeleteIgnoredSite').data('tr-id', $(this).closest('tr').attr('id'));
|
||||
$('#dialogDeleteIgnoredSite .modal-body:first strong:first').text($(this).closest('tr').children('td:first').text());
|
||||
$('#dialogDeleteIgnoredSite').modal('show');
|
||||
$('#dialogDeleteSite').data('url', $(this).closest('tr').data('url'));
|
||||
$('#dialogDeleteSite').data('tr-id', $(this).closest('tr').attr('id'));
|
||||
$('#dialogDeleteSite .modal-body:first strong:first').text($(this).closest('tr').children('td:first').text());
|
||||
$('#dialogDeleteSite').modal('show');
|
||||
});
|
||||
|
||||
$('#tab-ignored-sites tr.clone:first input[type=checkbox]:first').change(function() {
|
||||
$('#tab-site-preferences tr.clone:first input[type=checkbox]:first').change(function() {
|
||||
const url = $(this).closest('tr').data('url');
|
||||
for (let site of options.settings['ignoredSites']) {
|
||||
for (let site of options.settings['sitePreferences']) {
|
||||
if (site.url === url) {
|
||||
site.fullIgnore = $(this).is(':checked');
|
||||
site.usernameOnly = $(this).is(':checked');
|
||||
}
|
||||
}
|
||||
options.saveSettings();
|
||||
});
|
||||
|
||||
$("#ignoreUrl").keyup(function(event) {
|
||||
$('#tab-site-preferences tr.clone:first select:first').change(function() {
|
||||
const url = $(this).closest('tr').data('url');
|
||||
for (let site of options.settings['sitePreferences']) {
|
||||
if (site.url === url) {
|
||||
site.ignore = $(this).val();
|
||||
}
|
||||
}
|
||||
options.saveSettings();
|
||||
});
|
||||
|
||||
$("#manualUrl").keyup(function(event) {
|
||||
if (event.keyCode === 13) {
|
||||
$("#ignoreManualAddButton").click();
|
||||
$("#sitePreferencesManualAdd").click();
|
||||
}
|
||||
});
|
||||
|
||||
$('#ignoreManualAddButton').click(function(e) {
|
||||
$('#sitePreferencesManualAdd').click(function(e) {
|
||||
e.preventDefault();
|
||||
const value = $('#ignoreUrl').val();
|
||||
const value = $('#manualUrl').val();
|
||||
if (value.length > 10 && value.length <= 2000) {
|
||||
if (options.settings['ignoredSites'] === undefined) {
|
||||
options.settings['ignoredSites'] = [];
|
||||
if (options.settings['sitePreferences'] === undefined) {
|
||||
options.settings['sitePreferences'] = [];
|
||||
}
|
||||
|
||||
const newValue = options.settings['ignoredSites'].length + 1;
|
||||
const trClone = $('#tab-ignored-sites table tr.clone:first').clone(true);
|
||||
const newValue = options.settings['sitePreferences'].length + 1;
|
||||
const trClone = $('#tab-site-preferences table tr.clone:first').clone(true);
|
||||
trClone.removeClass('clone');
|
||||
|
||||
const tr = trClone.clone(true);
|
||||
tr.data('url', value);
|
||||
tr.attr('id', 'tr-scf' + newValue);
|
||||
tr.children('td:first').text(value);
|
||||
tr.children('td:nth-child(3)').children('input[type=checkbox]').attr('checked', false);
|
||||
$('#tab-ignored-sites table tbody:first').append(tr);
|
||||
$('#tab-ignored-sites table tbody:first tr.empty:first').hide();
|
||||
tr.children('td:nth-child(2)').children('select').val(IGNORE_NORMAL);
|
||||
$('#tab-site-preferences table tbody:first').append(tr);
|
||||
$('#tab-site-preferences table tbody:first tr.empty:first').hide();
|
||||
|
||||
options.settings['ignoredSites'].push({url: value, fullIgnore: false});
|
||||
options.settings['sitePreferences'].push({url: value, ignore: IGNORE_NORMAL, usernameOnly: false});
|
||||
options.saveSettings();
|
||||
|
||||
$('#ignoreUrl').val('');
|
||||
$('#manualUrl').val('');
|
||||
}
|
||||
});
|
||||
|
||||
$('#dialogDeleteIgnoredSite .modal-footer:first button.yes:first').click(function(e) {
|
||||
$('#dialogDeleteIgnoredSite').modal('hide');
|
||||
$('#dialogDeleteSite .modal-footer:first button.yes:first').click(function(e) {
|
||||
$('#dialogDeleteSite').modal('hide');
|
||||
|
||||
const url = $('#dialogDeleteIgnoredSite').data('url');
|
||||
const trId = $('#dialogDeleteIgnoredSite').data('tr-id');
|
||||
$('#tab-ignored-sites #' + trId).remove();
|
||||
const url = $('#dialogDeleteSite').data('url');
|
||||
const trId = $('#dialogDeleteSite').data('tr-id');
|
||||
$('#tab-site-preferences #' + trId).remove();
|
||||
|
||||
for (let i = 0; i < options.settings['ignoredSites'].length; ++i) {
|
||||
if (options.settings['ignoredSites'][i].url === url) {
|
||||
options.settings['ignoredSites'].splice(i, 1);
|
||||
for (let i = 0; i < options.settings['sitePreferences'].length; ++i) {
|
||||
if (options.settings['sitePreferences'][i].url === url) {
|
||||
options.settings['sitePreferences'].splice(i, 1);
|
||||
}
|
||||
}
|
||||
options.saveSettings();
|
||||
|
||||
if ($('#tab-ignored-sites table tbody:first tr').length > 2) {
|
||||
$('#tab-ignored-sites table tbody:first tr.empty:first').hide();
|
||||
if ($('#tab-site-preferences table tbody:first tr').length > 2) {
|
||||
$('#tab-site-preferences table tbody:first tr.empty:first').hide();
|
||||
} else {
|
||||
$('#tab-ignored-sites table tbody:first tr.empty:first').show();
|
||||
$('#tab-site-preferences table tbody:first tr.empty:first').show();
|
||||
}
|
||||
});
|
||||
|
||||
const trClone = $('#tab-ignored-sites table tr.clone:first').clone(true);
|
||||
const trClone = $('#tab-site-preferences table tr.clone:first').clone(true);
|
||||
trClone.removeClass('clone');
|
||||
let counter = 1;
|
||||
if (options.settings['ignoredSites']){
|
||||
for (let site of options.settings['ignoredSites']) {
|
||||
if (options.settings['sitePreferences']){
|
||||
for (let site of options.settings['sitePreferences']) {
|
||||
const tr = trClone.clone(true);
|
||||
tr.data('url', site.url);
|
||||
tr.attr('id', 'tr-scf' + counter);
|
||||
++counter;
|
||||
|
||||
tr.children('td:first').text(site.url);
|
||||
tr.children('td:nth-child(3)').children('input[type=checkbox]').attr('checked', site.fullIgnore);
|
||||
$('#tab-ignored-sites table tbody:first').append(tr);
|
||||
tr.children('td:nth-child(2)').children('select').val(site.ignore);
|
||||
tr.children('td:nth-child(3)').children('input[type=checkbox]').attr('checked', site.usernameOnly);
|
||||
$('#tab-site-preferences table tbody:first').append(tr);
|
||||
}
|
||||
}
|
||||
|
||||
if ($('#tab-ignored-sites table tbody:first tr').length > 2) {
|
||||
$('#tab-ignored-sites table tbody:first tr.empty:first').hide();
|
||||
if ($('#tab-site-preferences table tbody:first tr').length > 2) {
|
||||
$('#tab-site-preferences table tbody:first tr.empty:first').hide();
|
||||
} else {
|
||||
$('#tab-ignored-sites table tbody:first tr.empty:first').show();
|
||||
$('#tab-site-preferences table tbody:first tr.empty:first').show();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue