Skip to content

Commit

Permalink
Revert "Make injection of inpage.js on dapps synchronous"
Browse files Browse the repository at this point in the history
This reverts commit bec0fca.
  • Loading branch information
Lbqds committed Jan 17, 2025
1 parent e3f10da commit bba5adc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 40 deletions.
6 changes: 0 additions & 6 deletions packages/extension/manifest/v3.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,11 @@
"default_title": "Alephium",
"default_popup": "index.html"
},
"host_permissions": [
"file://*/*",
"http://*/*",
"https://*/*"
],
"permissions": [
"alarms",
"tabs",
"storage",
"notifications",
"scripting",
"http://localhost/*",
"https://node.testnet.alephium.org/*",
"https://backend.testnet.alephium.org/*",
Expand Down
21 changes: 0 additions & 21 deletions packages/extension/src/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,24 +197,3 @@ messageStream.subscribe(async ([msg, sender]) => {
// open onboarding flow on initial install

initOnboarding()

const registerInPageContentScript = async () => {
try {
await browser.scripting.registerContentScripts([
{
id: 'inpage',
matches: ["<all_urls>"],
js: ['inpage.js'],
runAt: 'document_start',
world: 'MAIN',
allFrames: true,
},
]);
} catch (err) {
console.warn(`Dropped attempt to register inpage content script. ${err}`);
}
};

if (browser.runtime.getManifest().manifest_version === 3) {
registerInPageContentScript();
}
19 changes: 6 additions & 13 deletions packages/extension/src/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,14 @@ import { WindowMessageType } from "./shared/messages"
import { messageStream, sendMessage } from "./shared/messages"

const container = document.head || document.documentElement
const script = document.createElement("script")

script.src = browser.runtime.getURL("inpage.js")
const alephiumExtensionId = browser.runtime.id
script.id = "alephium-extension"
script.setAttribute("data-extension-id", alephiumExtensionId)

let tag: HTMLElement
if (browser.runtime.getManifest().manifest_version === 3) {
const divTag = document.createElement("div")
divTag.style.display = 'none'
tag = divTag
} else {
const scriptTag = document.createElement("script")
scriptTag.src = browser.runtime.getURL("inpage.js")
tag = scriptTag
}
tag.id = 'alephium-extension'
tag.setAttribute('data-extension-id', alephiumExtensionId)
container.insertBefore(tag, container.children[0])
container.insertBefore(script, container.children[0])

window.addEventListener(
"message",
Expand Down

0 comments on commit bba5adc

Please sign in to comment.