从内容脚本访问本地资源
有没有办法可以访问脚本中的本地资源? 我需要访问 data.url('layout.html')
、data.url('icon.png')
和 data.url('style. css')
在 contentScript 处理程序中。
exports.main = function() {
require("widget").Widget({
onClick: function() {
tabs.activeTab.attach({
contentScriptFile: [ data.url('jquery.js')],
contentScript:
"setTimeout(function(){ alert('asd');}, 100);",
});
}
});
}
Is there a way i can access local resources inside a script?
I need to access data.url('layout.html')
, data.url('icon.png')
and data.url('style.css')
inside the contentScript handler.
exports.main = function() {
require("widget").Widget({
onClick: function() {
tabs.activeTab.attach({
contentScriptFile: [ data.url('jquery.js')],
contentScript:
"setTimeout(function(){ alert('asd');}, 100);",
});
}
});
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我最终使用了
cssUrl = data.url('alert.css')
。在 main.js 中我进行了设置,并在运行客户端的脚本中添加一个具有href=cssUrl
的脚本。I've ended up using
cssUrl = data.url('alert.css')
. In main.js i set this up, and in the script running client-side add a script havinghref=cssUrl
.使用 contentScriptOptions 将其传递给内容脚本,如下所示:
Use contentScriptOptions to pass it to the content script, like this: