[mv3] Add ability to reset to default settings

This commit is contained in:
Raymond Hill 2025-12-25 16:32:38 -05:00
parent 37d995eeac
commit 6063d4f0ad
No known key found for this signature in database
GPG key ID: F5630CAE62A14316
3 changed files with 21 additions and 1 deletions

View file

@ -383,6 +383,14 @@
"message": "Restore…", "message": "Restore…",
"description": "Text for buttons used to restore content" "description": "Text for buttons used to restore content"
}, },
"resetToDefaultButton": {
"message": "Reset to default settings…",
"description": "Text for buttons used to reset configurations to default"
},
"resetToDefaultConfirm": {
"message": "All your custom settings will be removed. Do you really want to reset to default settings?",
"description": "Message asking user to confirm reset to default settings"
},
"dnrRulesWarning": { "dnrRulesWarning": {
"message": "Do not add content from untrusted sources", "message": "Do not add content from untrusted sources",
"description": "Short description of the DNR rules editor pane" "description": "Short description of the DNR rules editor pane"

View file

@ -103,6 +103,7 @@
<p> <p>
<button class="iconified dontshrink" type="button"><span class="fa-icon">download-alt</span><span data-i18n="backupButton">_</span><span class="hover"></span></button> <button class="iconified dontshrink" type="button"><span class="fa-icon">download-alt</span><span data-i18n="backupButton">_</span><span class="hover"></span></button>
<button class="iconified dontshrink" type="button"><span class="fa-icon">upload-alt</span><span data-i18n="restoreButton">_</span><span class="hover"></span></button><input type="file" accept="application/json"> <button class="iconified dontshrink" type="button"><span class="fa-icon">upload-alt</span><span data-i18n="restoreButton">_</span><span class="hover"></span></button><input type="file" accept="application/json">
<button class="iconified dontshrink" type="button"><span class="fa-icon">undo</span><span data-i18n="resetToDefaultButton">_</span><span class="hover"></span></button><input type="file" accept="application/json">
</p> </p>
</div> </div>
</section> </section>

View file

@ -19,7 +19,7 @@
Home: https://github.com/gorhill/uBlock Home: https://github.com/gorhill/uBlock
*/ */
import { browser, sendMessage } from './ext.js'; import { browser, i18n, sendMessage } from './ext.js';
import { dom, qs$ } from './dom.js'; import { dom, qs$ } from './dom.js';
import { hashFromIterable } from './dashboard.js'; import { hashFromIterable } from './dashboard.js';
import { renderFilterLists } from './filter-lists.js'; import { renderFilterLists } from './filter-lists.js';
@ -173,6 +173,13 @@ async function restoreSettings() {
input.click(); input.click();
} }
async function resetSettings() {
const response = self.confirm(i18n.getMessage('resetToDefaultConfirm'));
if ( response !== true ) { return; }
const api = await import('./backup-restore.js');
await api.restoreFromObject({});
}
/******************************************************************************/ /******************************************************************************/
dom.on('#autoReload input[type="checkbox"]', 'change', ev => { dom.on('#autoReload input[type="checkbox"]', 'change', ev => {
@ -210,6 +217,10 @@ dom.on('section[data-pane="settings"] [data-i18n="restoreButton"]', 'click', ( )
restoreSettings(); restoreSettings();
}); });
dom.on('section[data-pane="settings"] [data-i18n="resetToDefaultButton"]', 'click', ( ) => {
resetSettings();
});
/******************************************************************************/ /******************************************************************************/
function listen() { function listen() {