Use background page path instead of generated path
if extension use manifest.background.page
This commit is contained in:
parent
76f4bd01eb
commit
d4f64ce943
1 changed files with 8 additions and 5 deletions
|
@ -73,9 +73,12 @@ const startBackgroundPages = function (manifest) {
|
|||
if (backgroundPages[manifest.extensionId] || !manifest.background) return
|
||||
|
||||
let html
|
||||
let name
|
||||
if (manifest.background.page) {
|
||||
name = manifest.background.page
|
||||
html = fs.readFileSync(path.join(manifest.srcDirectory, manifest.background.page))
|
||||
} else {
|
||||
name = '_generated_background_page.html'
|
||||
const scripts = manifest.background.scripts.map((name) => {
|
||||
return `<script src="${name}"></script>`
|
||||
}).join('')
|
||||
|
@ -86,12 +89,12 @@ const startBackgroundPages = function (manifest) {
|
|||
isBackgroundPage: true,
|
||||
commandLineSwitches: ['--background-page']
|
||||
})
|
||||
backgroundPages[manifest.extensionId] = { html: html, webContents: contents }
|
||||
backgroundPages[manifest.extensionId] = { html: html, webContents: contents, name: name }
|
||||
contents.loadURL(url.format({
|
||||
protocol: 'chrome-extension',
|
||||
slashes: true,
|
||||
hostname: manifest.extensionId,
|
||||
pathname: '_generated_background_page.html'
|
||||
pathname: name
|
||||
}))
|
||||
}
|
||||
|
||||
|
@ -314,11 +317,11 @@ app.once('ready', function () {
|
|||
const manifest = manifestMap[parsed.hostname]
|
||||
if (!manifest) return callback()
|
||||
|
||||
if (parsed.path === '/_generated_background_page.html' &&
|
||||
backgroundPages[parsed.hostname]) {
|
||||
const page = backgroundPages[parsed.hostname]
|
||||
if (page && parsed.path === `/${page.name}`) {
|
||||
return callback({
|
||||
mimeType: 'text/html',
|
||||
data: backgroundPages[parsed.hostname].html
|
||||
data: page.html
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue