aboutsummaryrefslogtreecommitdiffstats
path: root/js/settings.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/settings.js')
-rw-r--r--js/settings.js124
1 files changed, 62 insertions, 62 deletions
diff --git a/js/settings.js b/js/settings.js
index 5694b83..a9e11b4 100644
--- a/js/settings.js
+++ b/js/settings.js
@@ -2,7 +2,7 @@
ηMatrix - a browser extension to black/white list requests.
Copyright (C) 2014-2019 Raymond Hill
- Copyright (C) 2019-2020 Alessio Vanni
+ Copyright (C) 2019-2022 Alessio Vanni
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
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see {http://www.gnu.org/licenses/}.
- Home: https://libregit.spks.xyz/heckyel/ematrix
+ Home: https://gitlab.com/vannilla/ematrix
uMatrix Home: https://github.com/gorhill/uMatrix
*/
@@ -27,100 +27,100 @@
let cachedSettings = {};
function changeUserSettings(name, value) {
- vAPI.messaging.send('settings.js', {
+ vAPI.messaging.send('settings.js', {
what: 'userSettings',
name: name,
value: value
- });
+ });
}
function changeMatrixSwitch(name, state) {
- vAPI.messaging.send('settings.js', {
+ vAPI.messaging.send('settings.js', {
what: 'setMatrixSwitch',
switchName: name,
state: state
- });
+ });
}
function onChangeValueHandler(elem, setting, min, max) {
- let oldVal = cachedSettings.userSettings[setting];
- let newVal = Math.round(parseFloat(elem.value));
- if (typeof newVal !== 'number') {
+ let oldVal = cachedSettings.userSettings[setting];
+ let newVal = Math.round(parseFloat(elem.value));
+ if (typeof newVal !== 'number') {
newVal = oldVal;
- } else {
+ } else {
newVal = Math.max(newVal, min);
newVal = Math.min(newVal, max);
- }
- elem.value = newVal;
- if (newVal !== oldVal) {
+ }
+ elem.value = newVal;
+ if (newVal !== oldVal) {
changeUserSettings(setting, newVal);
- }
+ }
}
function prepareToDie() {
- onChangeValueHandler(uDom.nodeFromId('deleteUnusedSessionCookiesAfter'),
- 'deleteUnusedSessionCookiesAfter',
- 15, 1440);
- onChangeValueHandler(uDom.nodeFromId('clearBrowserCacheAfter'),
- 'clearBrowserCacheAfter',
- 15, 1440);
+ onChangeValueHandler(uDom.nodeFromId('deleteUnusedSessionCookiesAfter'),
+ 'deleteUnusedSessionCookiesAfter',
+ 15, 1440);
+ onChangeValueHandler(uDom.nodeFromId('clearBrowserCacheAfter'),
+ 'clearBrowserCacheAfter',
+ 15, 1440);
}
function onInputChanged(ev) {
- let target = ev.target;
+ let target = ev.target;
- switch (target.id) {
- case 'displayTextSize':
+ switch (target.id) {
+ case 'displayTextSize':
changeUserSettings('displayTextSize', target.value + 'px');
break;
- case 'clearBrowserCache':
- case 'cloudStorageEnabled':
- case 'collapseBlacklisted':
- case 'colorBlindFriendly':
- case 'deleteCookies':
- case 'deleteLocalStorage':
- case 'deleteUnusedSessionCookies':
- case 'iconBadgeEnabled':
- case 'processHyperlinkAuditing':
- case 'disableUpdateIcon':
- case 'resolveCname':
- changeUserSettings(target.id, target.checked);
- break;
- case 'collapseBlocked':
+ case 'clearBrowserCache':
+ case 'cloudStorageEnabled':
+ case 'collapseBlacklisted':
+ case 'colorBlindFriendly':
+ case 'deleteCookies':
+ case 'deleteLocalStorage':
+ case 'deleteUnusedSessionCookies':
+ case 'iconBadgeEnabled':
+ case 'processHyperlinkAuditing':
+ case 'disableUpdateIcon':
+ case 'resolveCname':
changeUserSettings(target.id, target.checked);
- synchronizeWidgets();
break;
- case 'noMixedContent':
- case 'noscriptTagsSpoofed':
- case 'processReferer':
+ case 'collapseBlocked':
+ changeUserSettings(target.id, target.checked);
+ synchronizeWidgets();
+ break;
+ case 'noMixedContent':
+ case 'noscriptTagsSpoofed':
+ case 'processReferer':
changeMatrixSwitch(target.getAttribute('data-matrix-switch'),
- target.checked);
+ target.checked);
break;
- case 'deleteUnusedSessionCookiesAfter':
+ case 'deleteUnusedSessionCookiesAfter':
onChangeValueHandler(target, 'deleteUnusedSessionCookiesAfter',
- 15, 1440);
+ 15, 1440);
break;
- case 'clearBrowserCacheAfter':
+ case 'clearBrowserCacheAfter':
onChangeValueHandler(target, 'clearBrowserCacheAfter', 15, 1440);
break;
- case 'popupScopeLevel':
+ case 'popupScopeLevel':
changeUserSettings('popupScopeLevel', target.value);
break;
- default:
+ default:
break;
- }
+ }
}
function synchronizeWidgets() {
- let e1, e2;
+ let e1, e2;
- e1 = uDom.nodeFromId('collapseBlocked');
- e2 = uDom.nodeFromId('collapseBlacklisted');
- if (e1.checked) {
+ e1 = uDom.nodeFromId('collapseBlocked');
+ e2 = uDom.nodeFromId('collapseBlacklisted');
+ if (e1.checked) {
e2.setAttribute('disabled', '');
- } else {
+ } else {
e2.removeAttribute('disabled');
- }
+ }
}
let onSettingsReceived = function (settings) {
@@ -131,24 +131,24 @@
let matrixSwitches = settings.matrixSwitches;
uDom('[data-setting-bool]').forEach(function (elem) {
- elem.prop('checked', userSettings[elem.prop('id')] === true);
+ elem.prop('checked', userSettings[elem.prop('id')] === true);
});
uDom('[data-matrix-switch]').forEach(function (elem) {
- let switchName = elem.attr('data-matrix-switch');
- if (typeof switchName === 'string' && switchName !== '') {
+ let switchName = elem.attr('data-matrix-switch');
+ if (typeof switchName === 'string' && switchName !== '') {
elem.prop('checked', matrixSwitches[switchName] === true);
- }
+ }
});
uDom.nodeFromId('displayTextSize').value =
- parseInt(userSettings.displayTextSize, 10) || 14;
+ parseInt(userSettings.displayTextSize, 10) || 14;
uDom.nodeFromId('popupScopeLevel').value = userSettings.popupScopeLevel;
uDom.nodeFromId('deleteUnusedSessionCookiesAfter').value =
- userSettings.deleteUnusedSessionCookiesAfter;
+ userSettings.deleteUnusedSessionCookiesAfter;
uDom.nodeFromId('clearBrowserCacheAfter').value =
- userSettings.clearBrowserCacheAfter;
+ userSettings.clearBrowserCacheAfter;
synchronizeWidgets();
@@ -159,6 +159,6 @@
}
vAPI.messaging.send('settings.js', {
- what: 'getUserSettings'
+ what: 'getUserSettings'
}, onSettingsReceived);
})();