Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update default twitter plugin and bump version #132

Merged
merged 2 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading