chore: update default twitter plugin and bump version (#132)

This commit is contained in:
tsukino
2025-01-21 20:00:11 -05:00
committed by GitHub
parent 06dc4fac83
commit efb4386d1b
5 changed files with 37 additions and 14 deletions

4
package-lock.json generated
View File

@@ -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",

View File

@@ -1,6 +1,6 @@
{
"name": "tlsn-extension",
"version": "0.1.0.702",
"version": "0.1.0.703",
"license": "MIT",
"repository": {
"type": "git",

View File

@@ -471,11 +471,13 @@ export async function getSessionStorageByHost(host: string) {
return ret;
}
async function getDefaultPluginsInstalled(): Promise<boolean> {
async function getDefaultPluginsInstalled(): Promise<string | boolean> {
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);
});

View File

@@ -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');