forked from darkreader/darkreader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui-highlights.ts
More file actions
28 lines (22 loc) · 892 Bytes
/
Copy pathui-highlights.ts
File metadata and controls
28 lines (22 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import {readLocalStorage, writeLocalStorage} from './utils/extension-api';
const proposedHighlights = [
'new-toggle-menus',
];
const KEY_UI_HIDDEN_HIGHLIGHTS = 'ui-hidden-highlights';
async function getHiddenHighlights() {
const options = await readLocalStorage({[KEY_UI_HIDDEN_HIGHLIGHTS]: [] as string[]});
return options[KEY_UI_HIDDEN_HIGHLIGHTS];
}
async function getHighlightsToShow(): Promise<string[]> {
const hiddenHighlights = await getHiddenHighlights();
return proposedHighlights.filter((h) => !hiddenHighlights.includes(h));
}
async function hideHighlights(keys: string[]): Promise<void> {
const hiddenHighlights = await getHiddenHighlights();
const update = Array.from(new Set([...hiddenHighlights, ...keys]));
await writeLocalStorage({[KEY_UI_HIDDEN_HIGHLIGHTS]: update});
}
export default {
getHighlightsToShow,
hideHighlights,
};