Skip to content

Commit

Permalink
chore: update default twitter plugin and bump version (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xtsukino authored Jan 22, 2025
1 parent 06dc4fa commit efb4386
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 14 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tlsn-extension",
"version": "0.1.0.702",
"version": "0.1.0.703",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
Binary file modified src/assets/plugins/twitter_profile.wasm
Binary file not shown.
6 changes: 4 additions & 2 deletions src/entries/Background/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
39 changes: 30 additions & 9 deletions src/entries/Background/index.ts
Original file line number Diff line number Diff line change
@@ -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 () => {
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit efb4386

Please sign in to comment.