“未知错误”在我的 Chrome 扩展程序中
我正在编写(或尝试编写)我的第一个 Chrome 扩展程序,但我无法弄清楚我不断收到的错误。我的后台代码是
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
console.log('works?');
chrome.tabs.executeScript(null, {code:"document.body.style.fontSize = 20"});
console.log('print again');
</script>
</body>
当我尝试运行此扩展时,出现错误: tabs.executeScript 期间出错:未知错误。扩展/扩展进程绑定.js:85
有谁知道这可能是什么或如何修复它?当我不包含 chrome.tabs.executeScript 行时,我不会收到错误,并且无论我为 chrome.tabs.executeScript 的参数编写什么,我都会收到错误。 当我将 chrome.tabs.executeScript 包含在每当单击 browserAction 时调用的函数中时,我也会收到错误
任何帮助将不胜感激,谢谢!
I am writing (or attempting to write) my first Chrome extension, and I cannot figure out this error I keep getting. My background code is
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
console.log('works?');
chrome.tabs.executeScript(null, {code:"document.body.style.fontSize = 20"});
console.log('print again');
</script>
</body>
When I try to run this extension I get the error:
Error during tabs.executeScript: Unknown error. extensions/extension process bindings.js:85
Does anyone have any idea what this could possibly be or how to fix it? I get no error when I do not include the line chrome.tabs.executeScript, and I get the error no matter what I write for the parameters of chrome.tabs.executeScript.
I also get the error when I include chrome.tabs.executeScript inside a function that is called whenever the browserAction is clicked
Any help would be much appreciated, thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当后台页面首次加载时,您将代码注入到选定的选项卡中,这种情况发生在您无法注入任何内容的
chrome://extensions
页面上。不确定为什么您仍然在浏览器操作侦听器内收到错误,也许您仍然打开扩展页面?
You are injecting code into selected tab right when background page loads for the first time, which happens on
chrome://extensions
page where you cannot inject anything.Not sure why you are still getting error inside browser action listener, maybe you have extensions page still opened?