我有一个Chrome扩展程序内容脚本,我想在Trello看板上运行它。目前,它只包含以下内容:
console.log("Hello, world!");
当您通过内部链接(例如从“我的面板”页面)打开Trello面板页面时,内容脚本不会运行。但是,在刷新页面后它会运行。
我的manifest文件包含:
{
"manifest_version": 2,
"name": "Temp Ext",
"version": "1.0",
"content_scripts": [
{
"matches": ["*://trello.com/b/*"],
"js":["contentscript.js"]
}
]
}
有人可以帮忙解决为什么脚本不能在页面最初加载时运行吗?
编辑:更正问题,问题仅在跟随内部链接后出现,而非任何链接。
*://github.com/*/*.wiki
的内容脚本。我正在捕捉从github.com/*
页面转换到另一个页面的状态推送,但由于我没有加载维基页面,因此无法调用内容脚本。我将manifest.json
更改为{ "matches": ["*://github.com/*"], ...```
- PMorganCAbrowser.webNavigation.onHistoryStateUpdated.addListener(function(details) {browser.tabs.executeScript(null,{file:"contentscript.js"});});
权限很重要。我忘记设置它们并得到了未定义的错误。 - Mike