diff --git a/package-lock.json b/package-lock.json index a5a9a36..2034476 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "tlsn-extension", - "version": "0.1.0.700", + "version": "0.1.0.703", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "tlsn-extension", - "version": "0.1.0.700", + "version": "0.1.0.703", "license": "MIT", "dependencies": { "@extism/extism": "^1.0.2", diff --git a/package.json b/package.json index 3009508..c2bb4a6 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tlsn-extension", - "version": "0.1.0.702", + "version": "0.1.0.703", "license": "MIT", "repository": { "type": "git", diff --git a/src/assets/plugins/twitter_profile.wasm b/src/assets/plugins/twitter_profile.wasm index 25dee0a..c556eaa 100644 Binary files a/src/assets/plugins/twitter_profile.wasm and b/src/assets/plugins/twitter_profile.wasm differ diff --git a/src/entries/Background/db.ts b/src/entries/Background/db.ts index eacb887..217287b 100644 --- a/src/entries/Background/db.ts +++ b/src/entries/Background/db.ts @@ -471,11 +471,13 @@ export async function getSessionStorageByHost(host: string) { return ret; } -async function getDefaultPluginsInstalled(): Promise { +async function getDefaultPluginsInstalled(): Promise { return appDb.get(AppDatabaseKey.DefaultPluginsInstalled).catch(() => false); } -export async function setDefaultPluginsInstalled(installed = false) { +export async function setDefaultPluginsInstalled( + installed: string | boolean = false, +) { return mutex.runExclusive(async () => { await appDb.put(AppDatabaseKey.DefaultPluginsInstalled, installed); }); diff --git a/src/entries/Background/index.ts b/src/entries/Background/index.ts index 554bf82..7b0176f 100644 --- a/src/entries/Background/index.ts +++ b/src/entries/Background/index.ts @@ -1,7 +1,7 @@ import { onBeforeRequest, onResponseStarted, onSendHeaders } from './handlers'; import { deleteCacheByTabId } from './cache'; import browser from 'webextension-polyfill'; -import { getAppState, setDefaultPluginsInstalled } from './db'; +import { getAppState, removePlugin, setDefaultPluginsInstalled } from './db'; import { installPlugin } from './plugins/utils'; (async () => { @@ -35,15 +35,36 @@ import { installPlugin } from './plugins/utils'; const { defaultPluginsInstalled } = await getAppState(); - if (!defaultPluginsInstalled) { - try { - const twitterProfileUrl = browser.runtime.getURL('twitter_profile.wasm'); - const discordDmUrl = browser.runtime.getURL('discord_dm.wasm'); - await installPlugin(twitterProfileUrl); - await installPlugin(discordDmUrl); - } finally { - await setDefaultPluginsInstalled(true); + switch (defaultPluginsInstalled) { + case false: { + try { + const twitterProfileUrl = browser.runtime.getURL( + 'twitter_profile.wasm', + ); + const discordDmUrl = browser.runtime.getURL('discord_dm.wasm'); + await installPlugin(twitterProfileUrl); + await installPlugin(discordDmUrl); + } finally { + await setDefaultPluginsInstalled('0.1.0.703'); + } + break; } + case true: { + try { + await removePlugin( + '6931d2ad63340d3a1fb1a5c1e3f4454c5a518164d6de5ad272e744832355ee02', + ); + const twitterProfileUrl = browser.runtime.getURL( + 'twitter_profile.wasm', + ); + await installPlugin(twitterProfileUrl); + } finally { + await setDefaultPluginsInstalled('0.1.0.703'); + } + break; + } + case '0.1.0.703': + break; } const { initRPC } = await import('./rpc');