mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Support background.page in extension manifest
This commit is contained in:
@@ -72,10 +72,15 @@ const backgroundPages = {}
|
||||
const startBackgroundPages = function (manifest) {
|
||||
if (backgroundPages[manifest.extensionId] || !manifest.background) return
|
||||
|
||||
const scripts = manifest.background.scripts.map((name) => {
|
||||
return `<script src="${name}"></script>`
|
||||
}).join('')
|
||||
const html = new Buffer(`<html><body>${scripts}</body></html>`)
|
||||
let html
|
||||
if (manifest.background.page) {
|
||||
html = fs.readFileSync(path.join(manifest.srcDirectory, manifest.background.page))
|
||||
} else {
|
||||
const scripts = manifest.background.scripts.map((name) => {
|
||||
return `<script src="${name}"></script>`
|
||||
}).join('')
|
||||
html = new Buffer(`<html><body>${scripts}</body></html>`)
|
||||
}
|
||||
|
||||
const contents = webContents.create({
|
||||
isBackgroundPage: true,
|
||||
|
||||
Reference in New Issue
Block a user