mirror of
https://github.com/twofas/2fas-browser-extension.git
synced 2024-11-22 02:00:08 +01:00
#1458 AutoSubmit - remove excluded domain
This commit is contained in:
parent
b6424de9e0
commit
e697319ab9
@ -38,6 +38,8 @@
|
||||
"modalDisconnectDeviceText": "You are attempting to disconnect the device \"DEVICE_NAME\" from this browser extension. Are you sure?",
|
||||
"modalSafariResetHeader": "Browser Extension reset",
|
||||
"modalSafariResetText": "You are attempting to reset the 2FAS Browser Extension. Are you sure?",
|
||||
"modalExcludeDomainHeader": "Remove domain from excluded list",
|
||||
"modalExcludeDomainText": "You are attempting to remove domain \"DOMAIN\" from excluded list. Are you sure?",
|
||||
"noPairedDevices": "No paired devices found",
|
||||
"noExcludedDomains": "No excluded domains found",
|
||||
"deviceName": "Device name",
|
||||
|
@ -21,6 +21,8 @@
|
||||
"errorConfigFirstMessage": "Please configure 2FAS Extension first.",
|
||||
"errorRemoveDeviceBadDataTitle": "Device data error",
|
||||
"errorRemoveDeviceBadDataMessage": "Please refresh and try again.",
|
||||
"errorRemoveDomainBadDataTitle": "Domain data error",
|
||||
"errorRemoveDomainBadDataMessage": "Please refresh and try again.",
|
||||
"errorStorageCorruptedTitle": "Extension storage is corrupted",
|
||||
"errorStorageCorruptedMessage": "We will try to fix it for you. Please wait.",
|
||||
"errorInactiveTabTitle": "Inactive tab",
|
||||
@ -45,6 +47,8 @@
|
||||
"successSafariResetMessage": "Browser Extension configuration removed",
|
||||
"successDomainExcludedTitle": "Success",
|
||||
"successDomainExcludedMessage": "Domain added to excluded list",
|
||||
"successDomainExcludedRemovedTitle": "Success",
|
||||
"successDomainExcludedRemovedMessage": "Domain removed from excluded list",
|
||||
"infoNativeNotificationsTitle": "2FAS Notifications",
|
||||
"infoNativeNotificationsMessage": "From now on, you'll be receiving system notifications instead of 2FAS custom ones. If you'd like to change this, go to the ",
|
||||
"infoEnabledNativeNotifications": "extension's settings",
|
||||
|
@ -73,6 +73,10 @@ const config = {
|
||||
Title: browser.i18n.getMessage('errorRemoveDeviceBadDataTitle') || t.errorRemoveDeviceBadDataTitle,
|
||||
Message: browser.i18n.getMessage('errorRemoveDeviceBadDataMessage') || t.errorRemoveDeviceBadDataMessage
|
||||
},
|
||||
RemoveDomainBadData: {
|
||||
Title: browser.i18n.getMessage('errorRemoveDomainBadDataTitle') || t.errorRemoveDomainBadDataTitle,
|
||||
Message: browser.i18n.getMessage('errorRemoveDomainBadDataMessage') || t.errorRemoveDomainBadDataMessage
|
||||
},
|
||||
StorageCorrupted: {
|
||||
Title: browser.i18n.getMessage('errorStorageCorruptedTitle') || t.errorStorageCorruptedTitle,
|
||||
Message: browser.i18n.getMessage('errorStorageCorruptedMessage') || t.errorStorageCorruptedMessage
|
||||
@ -126,6 +130,10 @@ const config = {
|
||||
DomainExcluded: {
|
||||
Title: browser.i18n.getMessage('successDomainExcludedTitle') || t.successDomainExcludedTitle,
|
||||
Message: browser.i18n.getMessage('successDomainExcludedMessage') || t.successDomainExcludedMessage
|
||||
},
|
||||
DomainExcludedRemoved: {
|
||||
Title: browser.i18n.getMessage('successDomainExcludedRemovedTitle') || t.successDomainExcludedRemovedTitle,
|
||||
Message: browser.i18n.getMessage('successDomainExcludedRemovedMessage') || t.successDomainExcludedRemovedMessage
|
||||
}
|
||||
},
|
||||
Info: {
|
||||
|
@ -17,13 +17,12 @@
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
//
|
||||
|
||||
/* global alert */
|
||||
|
||||
const browser = require('webextension-polyfill');
|
||||
const { createElement, createSVGElement, createTextElement } = require('../../partials/DOMElements');
|
||||
const generateEmptyDomainRow = require('./generateEmptyDomainRow');
|
||||
const S = require('../../selectors');
|
||||
const trashSVG = require('../../images/page-icons/trash.svg');
|
||||
const removeDomain = require('./removeDomain');
|
||||
|
||||
const generateDomainsList = list => {
|
||||
if (!list) {
|
||||
@ -52,7 +51,7 @@ const generateDomainsList = list => {
|
||||
};
|
||||
|
||||
t.tr = createElement('tr');
|
||||
t.tr.dataset.deviceId = domain;
|
||||
t.tr.dataset.domain = domain;
|
||||
|
||||
t.td[0] = createElement('td');
|
||||
t.td[0].setAttribute('data-before-i18n', browser.i18n.getMessage('domain'));
|
||||
@ -65,7 +64,7 @@ const generateDomainsList = list => {
|
||||
t.td[1].setAttribute('data-before-i18n', browser.i18n.getMessage('optionsRemoveFromExcluded'));
|
||||
t.button = createElement('button');
|
||||
t.button.dataset.domain = domain;
|
||||
t.button.addEventListener('click', () => { alert('elo'); });
|
||||
t.button.addEventListener('click', removeDomain);
|
||||
|
||||
t.svg = createSVGElement(trashSVG);
|
||||
t.button.appendChild(t.svg);
|
||||
|
@ -40,6 +40,8 @@ exports.hideConfirmModal = require('./hideConfirmModal');
|
||||
exports.confirmModalBackdropClick = require('./confirmModalBackdropClick');
|
||||
exports.removeDevice = require('./removeDevice');
|
||||
exports.removeDeviceFromDOM = require('./removeDeviceFromDOM');
|
||||
exports.removeDomain = require('./removeDomain');
|
||||
exports.removeDomainFromDOM = require('./removeDomainFromDOM');
|
||||
exports.sendTestNotification = require('./sendTestNotification');
|
||||
exports.setAdvanced = require('./setAdvanced');
|
||||
exports.setExtName = require('./setExtName');
|
||||
|
60
src/optionsPage/functions/removeDomain.js
Normal file
60
src/optionsPage/functions/removeDomain.js
Normal file
@ -0,0 +1,60 @@
|
||||
//
|
||||
// This file is part of the 2FAS Browser Extension (https://github.com/twofas/2fas-browser-extension)
|
||||
// Copyright © 2023 Two Factor Authentication Service, Inc.
|
||||
// Contributed by Grzegorz Zając. All rights reserved.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
//
|
||||
|
||||
const config = require('../../config');
|
||||
const browser = require('webextension-polyfill');
|
||||
const { loadFromLocalStorage, saveToLocalStorage } = require('../../localStorage');
|
||||
const storeLog = require('../../partials/storeLog');
|
||||
const showConfirmModal = require('./showConfirmModal');
|
||||
const TwoFasNotification = require('../../notification');
|
||||
const removeDomainFromDOM = require('./removeDomainFromDOM');
|
||||
|
||||
const removeDomain = function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
const el = this;
|
||||
const domain = el?.dataset?.domain;
|
||||
|
||||
if (!domain) {
|
||||
return storeLog('error', 31, new Error('Wrong domain'), 'removeDomain')
|
||||
.then(() => TwoFasNotification.show(config.Texts.Error.RemoveDeviceBadData, null, true))
|
||||
.catch(() => {});
|
||||
}
|
||||
|
||||
showConfirmModal(
|
||||
browser.i18n.getMessage('modalExcludeDomainHeader'),
|
||||
browser.i18n.getMessage('modalExcludeDomainText').replace('DOMAIN', domain),
|
||||
() => {
|
||||
return loadFromLocalStorage(['autoSubmitExcludedDomains'])
|
||||
.then(data => {
|
||||
const newExcludedList = data.autoSubmitExcludedDomains.filter(d => d !== domain);
|
||||
return saveToLocalStorage({ autoSubmitExcludedDomains: newExcludedList }, {});
|
||||
})
|
||||
.then(() => removeDomainFromDOM(domain))
|
||||
.then(() => TwoFasNotification.show(config.Texts.Success.DomainExcludedRemoved))
|
||||
.catch(async err => {
|
||||
await storeLog('error', 22, err, 'removeDevice');
|
||||
return TwoFasNotification.show(config.Texts.Error.UndefinedError, null, true);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = removeDomain;
|
39
src/optionsPage/functions/removeDomainFromDOM.js
Normal file
39
src/optionsPage/functions/removeDomainFromDOM.js
Normal file
@ -0,0 +1,39 @@
|
||||
//
|
||||
// This file is part of the 2FAS Browser Extension (https://github.com/twofas/2fas-browser-extension)
|
||||
// Copyright © 2023 Two Factor Authentication Service, Inc.
|
||||
// Contributed by Grzegorz Zając. All rights reserved.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>
|
||||
//
|
||||
|
||||
const generateEmptyDomainRow = require('./generateEmptyDomainRow');
|
||||
const S = require('../../selectors');
|
||||
|
||||
const removeDomainFromDOM = domain => {
|
||||
const tr = document.querySelector(`tr[data-domain="${domain}"]`);
|
||||
|
||||
if (tr && typeof tr.remove === 'function') {
|
||||
tr.remove();
|
||||
}
|
||||
|
||||
const tbody = document.querySelector(S.optionsPage.autoSubmit.list);
|
||||
|
||||
if (tbody.childElementCount === 0) {
|
||||
generateEmptyDomainRow(tbody);
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
module.exports = removeDomainFromDOM;
|
@ -423,8 +423,8 @@
|
||||
color: $color;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
padding-bottom: 16px;
|
||||
padding-top: 16px;
|
||||
padding-bottom: 8px;
|
||||
padding-top: 8px;
|
||||
text-align: left;
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
|
Loading…
Reference in New Issue
Block a user