Skip to content

Commit

Permalink
🐛 Bookmarklet: Exclude localOnly config
Browse files Browse the repository at this point in the history
  • Loading branch information
richardfrost committed Aug 14, 2024
1 parent 6ca9674 commit 07a2341
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/script/optionPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Bookmarklet from '@APF/bookmarklet';
import Logger from '@APF/lib/logger';
import {
booleanToNumber,
deepCloneJson,
dynamicList,
exportToFile,
lastElement,
Expand Down Expand Up @@ -262,6 +263,15 @@ export default class OptionPage {
configText.value = JSON.stringify(config, null, 2);
}

get bookmarkletConfig() {
const clone = deepCloneJson(this.cfg);
const keysToRemove = [...this.cfg.Class._localOnlyKeys];
Object.keys(clone).forEach((key) => {
if (keysToRemove.includes(key)) delete clone[key];
});
return clone;
}

bulkEditorAddRow(word: string = '', data: WordOptions | undefined = undefined) {
const table = document.querySelector('#bulkWordEditorModal table#bulkWordEditorTable') as HTMLTableElement;
if (data === undefined) {
Expand Down Expand Up @@ -864,7 +874,7 @@ export default class OptionPage {

const bookmarkletConfig = document.querySelector('input[name="bookmarkletConfig"]:checked') as HTMLInputElement;
const bookmarkletLink = document.getElementById('bookmarkletLink') as HTMLAnchorElement;
const cfg = bookmarkletConfig.value == 'default' ? null : this.cfg;
const cfg = bookmarkletConfig.value == 'default' ? null : this.bookmarkletConfig;
const href = this.bookmarklet.href(cfg);
bookmarkletLink.href = href;
this.Class.enableBtn(bookmarkletLink);
Expand Down

0 comments on commit 07a2341

Please sign in to comment.