Support background.page in extension manifest
This commit is contained in:
parent
511dceda4e
commit
76f4bd01eb
1 changed files with 9 additions and 4 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue