feat: [extensions] background pages (#21591)
This commit is contained in:
parent
cf497ea478
commit
8bc0c92137
23 changed files with 477 additions and 11 deletions
|
@ -0,0 +1,4 @@
|
|||
/* eslint-disable no-undef */
|
||||
chrome.runtime.onMessage.addListener((message, sender, reply) => {
|
||||
reply({ message, sender })
|
||||
})
|
|
@ -0,0 +1,6 @@
|
|||
/* eslint-disable no-undef */
|
||||
chrome.runtime.sendMessage({ some: 'message' }, (response) => {
|
||||
const script = document.createElement('script')
|
||||
script.textContent = `require('electron').ipcRenderer.send('bg-page-message-response', ${JSON.stringify(response)})`
|
||||
document.documentElement.appendChild(script)
|
||||
})
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"name": "lazy-background-page",
|
||||
"version": "1.0",
|
||||
"background": {
|
||||
"scripts": ["background.js"],
|
||||
"persistent": false
|
||||
},
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["<all_urls>"],
|
||||
"js": ["content_script.js"],
|
||||
"run_at": "document_start"
|
||||
}
|
||||
],
|
||||
"manifest_version": 2
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue