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);",
});
}
开发者_如何学运维 });
}
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 having href=cssUrl
.
Use contentScriptOptions to pass it to the content script, like this:
//main.js
contentScriptFile: [ data.url('jquery.js')],
contentScriptOptions: {
cssUrl: data.url('alert.css')
}
// jquery.js
console.log(self.options.cssUrl)
精彩评论