-
Notifications
You must be signed in to change notification settings - Fork 76
browser.extension null #120
Copy link
Copy link
Open
Description
Describe the bug
var browser = injectionContext.browser; // browser=null
var extension = browser.extension, // fuck null
To Reproduce
- 配置vue.config.js
{
"pluginOptions": {
"browserExtension": {
"componentOptions": {
"contentScripts": {
"components": {
background: true,
contentScripts: true,
},
"entries": {
content: "src/content.js",
inject: "src/inject.js"
}
}
}
}
}
}- content.js中注入脚本inject.js
let content = chrome.extension.getURL("js/inject.js")
console.log(`[cc-inspector]注入脚本:${content}`);
let script = document.createElement('script')
script.setAttribute('type', 'text/javascript')
script.setAttribute('src', content)
script.onload = function () {
// 注入脚本执行完后移除掉
this.parentNode.removeChild(this);
}
document.body.appendChild(script)- npm run build-watch
package.json
"scripts":{
"build-watch": "vue-cli-service build --watch"
}
代码好像来自:
/* tslint:disable */
/* -------------------------------------------------- */
/* Start of Webpack Hot Extension Middleware */
/* ================================================== */
/* This will be converted into a lodash templ., any */
/* external argument must be provided using it */
/* -------------------------------------------------- */
Expected behavior
这个问题影响了我的开发体验,导致content无法注入的脚本无法正常工作
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
