Skip to content

Commit

Permalink
make ext work
Browse files Browse the repository at this point in the history
  • Loading branch information
binhnguyen2501 committed May 31, 2024
1 parent 3177183 commit c1d1fc2
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 29 deletions.
1 change: 0 additions & 1 deletion src/entries/background/extension-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ browser.runtime.onInstalled.addListener((details) => {
const reason = details.reason
if (reason === 'install') {
browser.tabs.create({ url: 'src/entries/onboard/index.html' });
browser.storage.sync.set({ defaultnewtab: true });
}
})

Expand Down
15 changes: 9 additions & 6 deletions src/entries/onboard/main.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// import "@webcomponents/webcomponentsjs/webcomponents-bundle.js";
import "@webcomponents/webcomponentsjs/webcomponents-bundle.js";
import App from "./App.svelte";
// import * as bg from "../background/main";
import * as browser from "webextension-polyfill";

// customElements.define("my-element", App);
const moduleLoader = Promise.resolve(true);

new App({
target: document.getElementById("app"),
});
moduleLoader.then((res) => {
browser.storage.sync.get("options").then((res) => {
new App({
target: document.getElementById("app"),
});
})
})
2 changes: 1 addition & 1 deletion src/entries/options/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "@webcomponents/webcomponentsjs/webcomponents-bundle.js";
import App from "./App.svelte";
import * as browser from "webextension-polyfill";

const moduleLoader = Promise.resolve(APP_TYPE.TYPE === 'WEB' ? import("../background/main") : true);
const moduleLoader = Promise.resolve(true);

moduleLoader.then((res) => {
browser.storage.sync.get("options").then((res) => {
Expand Down
20 changes: 9 additions & 11 deletions src/lib/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,15 @@ export const API_URL = import.meta.env.VITE_API_URL || "https://api-staging.getn
export const nimbus = createAxiosInterface({
baseURL: API_URL,
getHeaderAuthorize: () => {
if (APP_TYPE.TYPE === "WEB") {
const authToken = localStorage.getItem("auth_token");
const solanaToken = localStorage.getItem("solana_token");
const suiToken = localStorage.getItem("sui_token");
const tonToken = localStorage.getItem("ton_token");
const evmToken = localStorage.getItem("evm_token");
if (evmToken || solanaToken || suiToken || tonToken || authToken) {
return {
Authorization: `${evmToken || solanaToken || suiToken || tonToken || authToken}`,
};
}
const authToken = localStorage.getItem("auth_token");
const solanaToken = localStorage.getItem("solana_token");
const suiToken = localStorage.getItem("sui_token");
const tonToken = localStorage.getItem("ton_token");
const evmToken = localStorage.getItem("evm_token");
if (evmToken || solanaToken || suiToken || tonToken || authToken) {
return {
Authorization: `${evmToken || solanaToken || suiToken || tonToken || authToken}`,
};
}
},
});
Expand Down
3 changes: 1 addition & 2 deletions src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ const ManifestV3: Partial<chrome.runtime.ManifestV3> = {
matches: ["*://*/*"],
},
],
// permissions: ["identity", "storage", "unlimitedStorage", "activeTab"],
permissions: ["storage", "unlimitedStorage", "activeTab"],
permissions: ["identity", "storage", "unlimitedStorage", "activeTab"],
commands: {
"open-quick-search": {
suggested_key: {
Expand Down
4 changes: 1 addition & 3 deletions src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/// <reference types="svelte" />
/// <reference types="vite/client" />
/// <reference types="@samrum/vite-plugin-web-extension/client" />

declare const APP_TYPE: { TYPE: string }
/// <reference types="@samrum/vite-plugin-web-extension/client" />
5 changes: 0 additions & 5 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ export default defineConfig(({ mode }) => {
"~": path.resolve(__dirname, "./src"),
},
},
define: {
APP_TYPE: {
TYPE: "EXT",
},
},
build: {
rollupOptions: {
output: {
Expand Down

0 comments on commit c1d1fc2

Please sign in to comment.