Paste CSS in Firefox add on sdk

I was unable to add CSS to the Firefox extension. Here is my code.

var tbb = require('toolbarbutton').ToolbarButton({ id: 'button', label: 'us-button', image: self.data.url('img/on.png'), onCommand: function () { tabs.activeTab.attach ({ contentScriptFile: [ self.data.url('jquery/jquery.min.js'), self.data.url('jquery/jquery-ui.js'), self.data.url('recuperation.js'), self.data.url('dialog.js') ], contentStyleFile: self.data.url('jquery/jquery-ui.css'), 

I use Eric Wold toolbar buttons . contentStyleFile does not seem to work. When I click on the button, the jQuery dialog box appears, but without the css file.

+6
source share
1 answer

You can get away with PageMod , which will bring the desired stylesheet and can also add JavaScript.

Something like this might work:

 var pm = require("sdk/page-mod").PageMod({ include: tabs.activeTab.url, attachTo: ["existing", "top"], contentScriptFile: [ self.data.url('jquery/jquery.min.js'), self.data.url('jquery/jquery-ui.js'), self.data.url('recuperation.js'), self.data.url('dialog.js') ], contentStyleFile: self.data.url('jquery/jquery-ui.css') }); 

Then later, you will want to destroy this PageMod when you are done with it so that they do not just hang over the pages attached to the old ones.

 pm.destroy(); 
+2
source

Source: https://habr.com/ru/post/946006/


All Articles