changes: for 1.2.3

This commit is contained in:
Andrei O 2023-02-21 22:28:15 +02:00
parent a74e4a5814
commit efca3756d1
No known key found for this signature in database
GPG Key ID: B961E5B68389457E
5 changed files with 34 additions and 28 deletions

View File

@ -1,5 +1,11 @@
# Changelog # Changelog
## Manifest Version 1.2.3
- injected stub with chrome feature available in chrome 103 ( register world ) to bypass CSP
- clear up some console errors
- pushed minimum version to 103
## Manifest Version 1.2.2 ## Manifest Version 1.2.2
- updated dependencies - updated dependencies

View File

@ -1,21 +1,6 @@
(() =>{ (() =>{
try { try {
// sha256-QANFAnmGYlNymbZUT9oHee/3HE1z/X5Qcngml3GzhVY=
const metamaskStub = `
// Add MetamaskAPI STUB for wallets lib to detect wallet exists
window.ethereum = {
isMetaMask: true,
isConnected: () => true,
request: (a,b,c) => window.ethereum.request(a,b,c),
sendAsync: (a,b,c) => window.ethereum.sendAsync(a,b,c),
send: (a,b,c) => window.ethereum.send(a,b,c),
}
`;
document.documentElement.setAttribute('onreset', metamaskStub);
document.documentElement.dispatchEvent(new CustomEvent('reset'));
document.documentElement.removeAttribute('onreset');
const container = document.documentElement; const container = document.documentElement;
const script = document.createElement('script'); const script = document.createElement('script');
script.setAttribute('async', "false") script.setAttribute('async', "false")
@ -26,9 +11,6 @@
} catch (error) { } catch (error) {
console.error('MetaMask: Provider injection failed.', error); console.error('MetaMask: Provider injection failed.', error);
} }
chrome.runtime.connect({
name: 'content'
})
})() })()
const allowedMethods = { const allowedMethods = {

View File

@ -20,7 +20,7 @@
"128": "assets/extension-icon/wallet_128.png" "128": "assets/extension-icon/wallet_128.png"
} }
}, },
"minimum_chrome_version": "94", "minimum_chrome_version": "103",
"permissions": [ "permissions": [
"notifications", "notifications",
"storage", "storage",
@ -45,6 +45,16 @@
"all_frames": true, "all_frames": true,
"run_at": "document_start", "run_at": "document_start",
"js": ["/src/extension/content.ts"] "js": ["/src/extension/content.ts"]
},
{
"matches": [
"http://*/*",
"https://*/*"
],
"all_frames": true,
"run_at": "document_start",
"js": ["/src/extension/metamask-stub.js"],
"world": "MAIN"
} }
], ],
"web_accessible_resources": [{ "web_accessible_resources": [{

View File

@ -0,0 +1,11 @@
try {
window.ethereum = {
isMetaMask: true,
isConnected: () => true,
request: (a,b,c) => window.ethereum.request(a,b,c),
sendAsync: (a,b,c) => window.ethereum.sendAsync(a,b,c),
send: (a,b,c) => window.ethereum.send(a,b,c),
}
} catch {
// ignore
}

View File

@ -10,23 +10,20 @@ let notificationUrl: string
chrome.runtime.onInstalled.addListener(() => { chrome.runtime.onInstalled.addListener(() => {
console.log('Service worker installed'); console.log('Service worker installed');
chrome.runtime.onConnect.addListener(port => port.onDisconnect.addListener(() =>
{
console.log('Service worker connected');
}))
chrome.runtime.connect(null as unknown as string, {
name:'sw-connection'
})
}) })
chrome.runtime.onStartup.addListener(() => { chrome.runtime.onStartup.addListener(() => {
console.log('Service worker startup'); console.log('Service worker startup');
if(chrome.runtime.lastError) {
console.warn("Whoops.. " + chrome.runtime.lastError.message);
}
}) })
chrome.runtime.onSuspend.addListener(() => { chrome.runtime.onSuspend.addListener(() => {
console.log('Service worker suspend'); console.log('Service worker suspend');
if(chrome.runtime.lastError) {
console.warn("Whoops.. " + chrome.runtime.lastError.message);
}
}) })