FAQ Database Discussion Community

setInterval not called in tab content-script

Simple use case: main.js var tabs = require('sdk/tabs'); tabs.open({ url: 'http://www.openstreetmap.org', onOpen: function (tab) { tab.attach({ contentScriptFile: './content.js' }); } }); content.js console.log("foo"); setInterval(function() { console.log("bar"); }, 1000); output foo I get the same problem with event handlers, which is more problematic…...

A way to activate a script on a tab in FireFox when a specific URL is opened

As the title says, I need my addon to execute a script that will inject some CSS when a specific URL is opened. How would one go about calling on a script to run?

How emit function in firefox extension?

Can i emit function from one file to another in firefox extension? Example: main.js data = function() { return fn(); } panel.port.emit("resp", data); panel.js self.port.on('resp', function(fn) { return fn("some"); }); ...

access custom dom function from firefox add-on

I am working on a Firefox Add, using the newest SDK. The problem I am having, is that when ever I try to run a custom dom function it doesn't work. Scenario: The firefox add-on must be able to loop through all tabs, and if the correct one is open...

Load image using crossOrigin attr. in Firefox addon sdk

In content script in Firefox addon SDK I'm loading image like this way: var img = new Image(); img.crossOrigin = "Anonymous"; img.src = URL; img.onload = function (data) { var canvas = document.createElement("canvas"); canvas.width =this.width; canvas.height =this.height; var ctx = canvas.getContext("2d"); ctx.drawImage(this, 0, 0); var dataURL = canvas.toDataURL("image/jpeg"); callback.call(this,dataURL); }...

JPM not working

I've just tried using JPM for the first time, and I can't get anything to work. My index.js file looks like this: const actionButton = require('sdk/ui/button/action'); const TAG = "Addon Scratchpad / Index "; console.log(TAG+'in index.js'); var button = actionButton.ActionButton({ id: "my-button", label: "my button", icon: { "16": "./tool-scratchpad-16.png", "32":...

How can open Firefox developer tools in my extension's sidebar?

I have developed a Firefox extension which includes a sidebar using the SDK. However, if I right-click inside the sidebar and choose "Inspect Element", I get this error in my terminal: JavaScript error: chrome://browser/content/nsContextMenu.js, line 570: TypeError: gBrowser is null Needless to say, nothing happens and the developer tools do...

Overriding `onClick` on a Firefox-Addon ActionButton

When creating a plain old ActionButton in a Firefox Add-on, it seems that one cannot override the onClick property after creation. Anyhow, this var handleClick = function() { tabs.open('https://www.mozilla.org/'); }; var button = new ActionButton({ id: 'my-link', label: 'label me', icon: { '16': './icon-16.png', '32': './icon-32.png', '64': './icon-64.png' }, onClick:...

Request object response always empty

Here's my main.js require('sdk/request').Request({ url:'https://google.com' ,onComplete:function(response){ console.log('response',response) } }).get() which gives me console.log: extension: response constructor {} At first I thought it was a permissions thing, but I whitelisted google and still no response "permissions": { "private-browsing": true ,"cross-domain-content":["https://google.com"] } I'm using FF31...

firefox extension works through sdk but not when installed in browser - compatibility issue?

---Update---- After experimenting more with this, I've determined that the contentScript I have written is not the problem here. For example, if I reduce the extension to merely: var buttons = require('sdk/ui/button/action'); var data = require("sdk/self").data; var self = require("sdk/self"); var button = buttons.ActionButton({ id: "library-link", label: "External Resource Locator",...

Firefox addon: TypeError: getBrowserForTab(…) is undefined

While attaching an object to window of the active tab in main.js, I get following error: Message: TypeError: getBrowserForTab(...) is undefined Here is the code that I've used to attach the object: var { getTabs, getTabContentWindow } = require('sdk/tabs/utils'); tabs.on('load', function(tab) { var window = getTabContentWindow(tab); window.myObject = { data:...

firefox extension: intercepting url it is requesting and blocking conditionally

in firefox extension I want to intercept the url browser is making request to and block the request entirely if some condition matches how can I intercept URL being requested...

Firefox addon SDK - attaching a stylesheet to a tab triggering an error

I'm trying to add a content script to a tab when the tab loads, but my code is throwing TypeError: window.QueryInterface is not a function' when I run the attachTo method. var attachTo = require('sdk/content/mod').attachTo; var style = require('sdk/stylesheet/style'); tabs.on('ready', function(tab) { var worker = tab.attach({ contentScriptFile: ['./content.js'] }); var...

Firefox addon uploading canvas contents to imgur

I am writing an addon in firefox that automatically sends the contents of a canvas to imgur. I have already built a similar extension in chrome, where it works as expected, so I know that the usage of imgurs API is correct. When I use the same approach in the...

Can I somehow listen on the URL user is typing with Firefox addon SDK?

Is there a way with Firefox Add-on SDK to get the URL while user is typing it in the location field?

Is there an API to control downloads in Firefox add-on SDK?

In Firefox, is there an API equivalent to Google Chrome's chrome.downloads API? I need to control downloads with functions such as pause, resume, and cancel. In addition, I want to be able to remove the downloaded file. If there is no API in Firefox add-on SDK, is it possible to...

Firefox addon - Catch post variables before submit [no enctype]

I have the following form: <form method="post" action="includes/do.php"> <input type="text" name="action" value="login" /> <input type="text" name="email" value="[email protected]" /> <input type="text" name="pass" value="helloworld" /> <input type="submit" value="Send" /> </form> Then, I want to catch the variables values before being submitted inside a firefox addon observer. Notice that the form DOESN'T have...

Right click does not work in panel (firefox addon-sdk)

i am creating a firefox addon using SDK and i was wondering why right click is not working inside the panel. Is there anyway to make it work ? or Is it meant to be in this form ?

Closing tabs with a specific meta TAG in firefox-addon using javascript

I have this addon which inserts the following "meta" TAG on the pages it opens.Towards the end, I want to close all the tabs with that TAG on the page header. <meta id="CLOSE_LATER"> I have written a simple for-loop: var TAG = "CLOSE_LATER"; var tabs = require("sdk/tabs"); for(var i=0; i<tabs.length;...

FireFox addon-sdk page-worker regex

According to MDN's page page-worker API, I should be able to use a Reg-ex as an argument to the include section of my function. var data = require("sdk/self").data; var page = require("sdk/page-worker"); var re = new RegExp("/.*google.*/"); function doTheThing(){ page.Page({ include: re, contentURL: data.url("webPage.html"), contentScriptWhen: "ready", contentScript: 'document.body.style.border = "5px...

how to append iframe to hosted page using Firefox SDK addon?

Assume frame.html inside data folder in Firefox SDK addon, how to append an iframe and define frame.html as its source? Additional info: Because of CPS, its not possible to use inline source, so I can't use data.load('frame.html'), I need to use URL of the file: lib/main.js tabs.activeTab.attach({ contentScriptFile: [self.data.url("js/appender.js") ],...

Why cfx run installs always an old copy of the extension

I followed this guide and then I made some changes (I added a sidebar which opens an HTML placed in the data folder). I executed "cfx run" and it worked, but now I'm just modifying the HTML and the changes are never displayed.

javascript firefox sdk: get domain without subdomain

what is an easy way to get the domain without the subdomain. For example in this URL: http://a.b.hllo.co.uk I want to retrieve hllo...

Badged Buttons from Non-SDK

Does anyone have any tricks on how to use the badged buttons feature of addon-sdk from non-sdk addons? https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/ui_button_action#Badged_buttons If no tricks my thinking was to use maybe override xbl and/or override display='xul:button' from techniques listed here: To anonymous element add pseudo element and cursor style and event listeners...

Compilation of firefox extension with xulrunner-sdk-36.0 C++

I have a FF toolbar working in all previous versions. My toolbar partially written in C++. I've tried to build the C++ part with a new xulrunner-sdk-36.0 I've receive such link errors: 1>xpcomglue_s.lib(nsISupportsImpl.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1800' doesn't match value '1600' in Encryption.obj 1>xpcomglue_s.lib(nsStringAPI.obj) :...

Errors in Firefox Add-on SDK when using cfx xpi whereas cfx run works great

I'm a student at a University Institute of Technology in France and I'm very new to Firefox add-on development since I discovered it at the beginning of my work placement, a few days ago. What I have to do is an add-on that allows employees of the company to organize...

best option for firefox extension to keep panel / overlay / sidebar visible between pages?

The Firefox SDK Panel disappears whenever the user interacts with the page. Does anyone have a suggestion of the best approach that will continue to work that would allow something like a panel, overlay or sidebar to remain active as the user changes pages? From what I've read, it looks...

How to create UI with Mozilla Addon SDK?

I want to crate an extension for Mozilla Firefox which process HTML code and generates screen reader output in a new window. I need to create a UI window (without tabs, panels and addressbar) and i´ve only found a tab and window method in SDK API which opens a new...

How to get notified whenever the URL in the address bar changes Firefox JPM

Is it possible to detect whether an URL changes, while developing Firefox addons using the new SDK/JPM? It's not exactly hashchange what I want to detect, but any changes to the URL, like ajax request changing search terms or things like that. Is it a way to do it? Thanks....

firefox bootstrap addon: install event is not executed

I'm trying to create a bootstrapped addon that just sets the new tab url at install to a new value and resets it to the old one when it gets uninstalled. Here is my bootstrap.js. I think the install function throws an exception because require is not defined, but I'm...

Firefox extension app hosted on server

I managed to create a Chrome extension pretty easy and the main application is hosted on my server allowing me to provide updates to the app itself without having to update the whole extension. I like the idea and I just want to know if it's possible to create a...

Using the Web Crypto API from Firefox AddOn

I can't figure out how to access the Web Crypto API from an AddOn script itself (no documentation). Trying to do it from a content-script gives a permission error accessing then: JavaScript error: resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/loader/sandbox.js -> resource://..../data/content-script.js, line 36: Error: Permission denied to access property "then" The relevant code...

File types change into .xml while downloading in Firefox

In my asp .net application we can upload doc files and after uploading files we can view it in browser. It is working in all browser, but there is one issue while view through Firefox, while clicking hyperlink view the file is being download, but file type changes into .xml...

It is possible to create a hyperlink to the JS debugger in firefox?

The webconsole from FF outputs a hyperlink to the js debugger/source when an error/warning occurs. Is it possible to create such a link in my own devtools extension. And when yes, how? ...

Firefox open file from add-on instead of local path

I am creating Firefox add-on which run a specific .bat file. This is code I used. main.js const {Components, Cc, Ci,Cu} = require("chrome"); var file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile); file.initWithPath("C:\\Users\\Madhawa.se\\Desktop\\snap\\shoot.bat"); // i want to open this bat from xpi .for example from data directory var args="this is an argument "; var process...

Detect tab url change inside firefox add-on

I have an extension that works on chrome that monitors the active Tab for url changes. Specifically i needed to detect when the url changed but there was no new page load or navigation, (some sites do this, like youtube when you click to view another video) On chrome i...

Copy to clipboard from Firefox add-on content script

I want to write a content script in a Firefox add-on that will copy a string to the user's clipboard in response to an event. I know that I can do this with the Firefox clipboard API like this: var clipboard = require("sdk/clipboard"); var val = "Lorem ipsum dolor sit...

Receive message from main.js in Firefox add-on content script

I'm trying to communicate between main.js and a content script. Here is my main.js: var pageMod = require('sdk/page-mod'); var self = require('sdk/self'); var ss = require('sdk/simple-storage'); pageMod.PageMod({ include: 'example.com', contentScriptFile: self.data.url('content-script.js'), onAttach: function(worker) { worker.port.on('getSetting', function(request) { // var settingValue = ss.storage[request] var settingValue = 'test value'; // for testing,...

How to generate update.rdf with jpm

Rather than cfx's --updateurl command, with jpm, we can simply place the updateURL in package.json. This URL points to a file called update.rdf, which tells self-hosted addons where to look for updates. With cfx, that update.rdf file could be generated with the --updatelink, but that option has been removed from...