Chrome扩展:QuerySelector上的null参数错误在内容脚本上
我正在创建一个镀铬扩展名,它将与Twitch Drops相互作用,并通知我是否准备好收集。我正在将内容脚本注入特定元素的类别,但它显示无法读取null的属性(读取'getAttribute')。 这是我的内容。JS代码:
var element = document.querySelector(".juerA");
var val = element.getAttribute('value');
console.log(val);
如果我在控制台上运行相同的代码,则可以正常运行。我尝试使用“ run_at”:“ document_end” ,但它不起作用。如果我将内容脚本的匹配与其他网页更改,则我还检查了扩展程序是否有效,并且可以正常工作。
I am creating a chrome extension that will interact with twitch drops and notify me if the drop is ready for collection. I am injecting a content script fetch attributes of a particular element by its class but it shows Cannot read properties of null (reading 'getAttribute').
Here is my content.js code:
var element = document.querySelector(".juerA");
var val = element.getAttribute('value');
console.log(val);
If I run the same code on the console, it works fine. I have tried using "run_at" : "document_end" but it doesn't work. I have also checked if the extension works if I change the matches of the content script with other web pages and it works.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论