Rename page and content scripts (self-explanatory) (#33)
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
"default_popup": "popup.html"
|
||||
},
|
||||
"content_scripts": [{
|
||||
"js": ["loader.js"],
|
||||
"js": ["content.js"],
|
||||
"matches": [
|
||||
"https://polkadot.js.org/apps/*",
|
||||
"http://localhost:3000/*"
|
||||
@@ -25,6 +25,6 @@
|
||||
"64": "images/icon-64.png",
|
||||
"128": "images/icon-128.png"
|
||||
},
|
||||
"web_accessible_resources": ["inject.js"],
|
||||
"web_accessible_resources": ["page.js"],
|
||||
"content_security_policy": "script-src 'self' 'unsafe-eval' 'wasm-eval'; object-src 'self'"
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"license": "Apache-2",
|
||||
"dependencies": {
|
||||
"@polkadot/api": "^0.80.0-beta.2",
|
||||
"@polkadot/api": "^0.80.0-beta.6",
|
||||
"@polkadot/extension-ui": "^0.1.1-beta.8",
|
||||
"@polkadot/ui-keyring": "^0.40.0-beta.1"
|
||||
},
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
import extension from 'extensionizer';
|
||||
|
||||
function sendResponse (data: any): void {
|
||||
window.postMessage({ ...data, origin: 'loader' }, '*');
|
||||
window.postMessage({ ...data, origin: 'content' }, '*');
|
||||
}
|
||||
|
||||
// Handle all messages, passing messages to the extension
|
||||
window.addEventListener('message', ({ data, source }) => {
|
||||
// only allow messages from our window, by the inject
|
||||
if (source !== window || data.origin !== 'inject') {
|
||||
if (source !== window || data.origin !== 'page') {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ window.addEventListener('message', ({ data, source }) => {
|
||||
// inject our data injector
|
||||
const script = document.createElement('script');
|
||||
|
||||
script.src = extension.extension.getURL('inject.js');
|
||||
script.src = extension.extension.getURL('page.js');
|
||||
script.onload = (): void => {
|
||||
// remove the injecting tag when loaded
|
||||
if (script.parentNode) {
|
||||
@@ -34,7 +34,7 @@ function sendMessage (message: MessageTypes, request: any = null): Promise<any>
|
||||
|
||||
callbacks[id] = { resolve, reject };
|
||||
|
||||
window.postMessage({ id, message, origin: 'inject', request }, '*');
|
||||
window.postMessage({ id, message, origin: 'page', request }, '*');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ async function enable (origin: string): Promise<Injected> {
|
||||
// setup a response listener (events created by the loader for extension responses)
|
||||
window.addEventListener('message', ({ data, source }) => {
|
||||
// only allow messages from our window, by the loader
|
||||
if (source !== window || data.origin !== 'loader') {
|
||||
if (source !== window || data.origin !== 'content') {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ function createWebpack ({ alias = {}, context }) {
|
||||
devtool: false,
|
||||
entry: {
|
||||
background: './src/background/index.ts',
|
||||
inject: './src/inject/index.ts',
|
||||
loader: './src/loader.ts',
|
||||
popup: `./src/views/popup.ts`
|
||||
content: './src/content.ts',
|
||||
page: './src/page/index.ts',
|
||||
popup: `./src/popup.ts`
|
||||
},
|
||||
mode: ENV,
|
||||
output: {
|
||||
|
||||
Reference in New Issue
Block a user