Compare commits

..

No commits in common. "6274e51752c31e02d68e52531e7ff66218252a56" and "6630eff27f5d5fa4de25a2f668a2ad7ea78e624f" have entirely different histories.

2 changed files with 6 additions and 17 deletions

View File

@ -16,22 +16,11 @@ browser.runtime.onInstalled.addListener(async () => {
if (import.meta.env.DEV) { if (import.meta.env.DEV) {
await browser.runtime.openOptionsPage(); await browser.runtime.openOptionsPage();
} }
const {dataVersion} = await browser.storage.sync.get({
dataVersion: '0',
});
if (dataVersion === '0') {
const local = await browser.storage.local.get();
local.dataVersion = '1';
await browser.storage.sync.set(local);
}
}); });
browser.webNavigation.onBeforeNavigate.addListener(async (details) => { browser.webNavigation.onBeforeNavigate.addListener(async (details) => {
const detailsUrl = new URL(details.url); const detailsUrl = new URL(details.url);
const supportedHosts = ['duckduckgo.com', 'google.com']; if (detailsUrl.host !== 'duckduckgo.com') {
if (supportedHosts.includes(detailsUrl.host)) {
return; return;
} }
@ -45,7 +34,7 @@ browser.webNavigation.onBeforeNavigate.addListener(async (details) => {
return; return;
} }
const data = await browser.storage.sync.get(id); const data = await browser.storage.local.get(id);
if (data[id] === undefined) { if (data[id] === undefined) {
return; return;
} }

View File

@ -34,9 +34,9 @@ export class PageMain extends Component<Props, State> {
} }
async componentDidMount() { async componentDidMount() {
const storage = await browser.storage.sync.get(); const localStorage = await browser.storage.local.get();
const bangs = Object.entries(storage) const bangs = Object.entries(localStorage)
.filter(([key, _bang]) => key.startsWith('!')) .filter(([key, _bang]) => key.startsWith('!'))
.map(([_key, bang]) => bang as BangParameters) .map(([_key, bang]) => bang as BangParameters)
.sort((a, b) => a.id.localeCompare(b.id)); .sort((a, b) => a.id.localeCompare(b.id));
@ -67,7 +67,7 @@ export class PageMain extends Component<Props, State> {
return; return;
} }
await browser.storage.sync.remove(id); await browser.storage.local.remove(id);
const bangs = this.state.bangs; const bangs = this.state.bangs;
const existingIndex = bangs.findIndex((bang) => bang.id === id); const existingIndex = bangs.findIndex((bang) => bang.id === id);
@ -88,7 +88,7 @@ export class PageMain extends Component<Props, State> {
if (Bang.validate(bang)) { if (Bang.validate(bang)) {
const update: Record<string, BangParameters> = {}; const update: Record<string, BangParameters> = {};
update[bang.id] = bang; update[bang.id] = bang;
await browser.storage.sync.set(update); await browser.storage.local.set(update);
} }
} catch (error: unknown) { } catch (error: unknown) {
if (error instanceof Error) { if (error instanceof Error) {