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

Rename page and content scripts (self-explanatory) #33

Merged
merged 1 commit into from
May 29, 2019
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"devDependencies": {
"@babel/core": "^7.4.5",
"@polkadot/dev-react": "^0.30.0-beta.5",
"@polkadot/dev-react": "^0.30.0-beta.6",
"@polkadot/ts": "^0.1.56"
}
}
4 changes: 2 additions & 2 deletions packages/extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/*"
Expand All @@ -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'"
}
2 changes: 1 addition & 1 deletion packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }, '*');
});
}

Expand All @@ -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;
}

Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions packages/extension/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
Loading