firefox-addon-sdk

Identify tab that made request in Firefox Addon SDK

只愿长相守 提交于 2019-12-30 02:27:06
问题 I'm using the Firefox Addon SDK to build something that monitors and displays the HTTP traffic in the browser. Similar to HTTPFox or Live HTTP Headers. I am interested in identifying which tab in the browser (if any) generated the request Using the observer-service I am monitoring for "http-on-examine-response" events. I have code like the following to identify the nsIDomWindow that generated the request: const observer = require("observer-service"), {Ci} = require("chrome"); function

Set preferences in the user branch and unset them on uninstall

六月ゝ 毕业季﹏ 提交于 2019-12-29 07:53:27
问题 I created a firefox add-on with the following lib/main.js: const {Cc,Ci} = require("chrome"); var pref = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch); pref.setIntPref("network.http.response.timeout", 3600*24); It wasn't accepted with the following reason: Add-ons which change critical settings must revert the changes when disabled or uninstalled. You should also make the changes in the default, rather than the user, branch. You need to call getDefaultBranch("") on the

Firefox Add-On window.navigator.userAgent error: window not defined

孤者浪人 提交于 2019-12-28 03:14:06
问题 I am trying to get userAgent and want to do some parsing on it: My code is: var userAgentInfo = { userAgent: null, init: function() { this.userAgent = window.navigator.userAgent;//ERROR }, getOS: function(UA) { //Some logic }, getDevice: function(UA) { //Some logic }, getBrowser: function(UA) { //Some logic }, }; Whenever I try to start/test this extension I receive the following error: Running tests on Firefox 24.3.0/Gecko 24.3.0 ({ec8030f7-c20a-464f-9b0e-13a3a9e97384}) under linux/x86-gcc3.

Are (Firefox add-on SDK) page-workers Twitter-incompatible?

隐身守侯 提交于 2019-12-25 16:56:42
问题 When I create page-workers for pages in the twitter.com domain, nothing happens. lib/main.js : var pw = require("sdk/page-worker"); pw.Page({ contentScript: "console.log(window.location.href)", contentURL: "https://google.com" }); pw.Page({ contentScript: "console.log(window.location.href)", contentURL: "https://twitter.com" }); Console output is as follows: console.log: twitter-worker: https://www.google.com/ That's all, folks. I haven't yet gotten a content script to run for any page-worker

Auto width widget

孤者浪人 提交于 2019-12-25 16:54:30
问题 I'm writing a small add-on to Firefofx, in which I use widgets. I wonder how to set auto-width which adapts to content. For example I want my widget to display numbers, which will have a different length. I can set my widget width but how do I know how much my number takes pixels. Is there a way to get the width, choosing automatically? Here is some of my code: My widget (my add-on uses other widgets), //ROBOTS META var robots_meta = widgets.Widget({ id: "robots_meta", label: "Displays

Addon attaches script just fine with jpm run, but not with the actual xpi

落花浮王杯 提交于 2019-12-25 16:01:29
问题 I'm still fairly new to the addon-sdk and have run into a for me unexplainable problem. So far, I've been using jpm run to test everything - and it all works great. Now, I'm getting close to be finished with what I want to accomplish, so I wanted to give it a test run in a 'normal' browser - mainly to use it over a couple of days to see if everything works as expected. However, the installing process already throws two error messages: [Exception... "Component returned failure code: 0x80004005

Addon attaches script just fine with jpm run, but not with the actual xpi

瘦欲@ 提交于 2019-12-25 16:01:18
问题 I'm still fairly new to the addon-sdk and have run into a for me unexplainable problem. So far, I've been using jpm run to test everything - and it all works great. Now, I'm getting close to be finished with what I want to accomplish, so I wanted to give it a test run in a 'normal' browser - mainly to use it over a couple of days to see if everything works as expected. However, the installing process already throws two error messages: [Exception... "Component returned failure code: 0x80004005

Create XPI package with the Add-on SDK?

拟墨画扇 提交于 2019-12-25 07:29:03
问题 I got task to write an add-on for Firefox which will add an div element to existing page. I downloaded Add-on SDK and wrote a main.js file that looks like this: var data = require("sdk/self").data; require("sdk/tabs").on("ready", ExecuteAd); function ExecuteAd(tab) { if ( tab.url.indexOf("some url checking") > -1 ) { var image = "http://www.lavasoft.com/img/product_icons/aaw11/free.png"; var link = "http://www.google.me"; tab.attach({ contentScriptFile: data.url("myscript.js"), contentScript:

ReferenceError: Worker is not defined in simple Firefox Extension

 ̄綄美尐妖づ 提交于 2019-12-25 04:51:58
问题 I'm creating an incredibly simple Firefox extension. I used cfx init to create the directory structure and have code in lib/main.js and data/my_worker.js main.js is as follows: var worker = new Worker("my_worker.js"); worker.onmessage = function(e) { console.log(e.data); }; worker.postMessage("Bobby"); and my_worker.js is as follows: self.onmessage = function(e) { self.postMessage("Hello " + e.data); }; Then I run: cfx run to run the extension. The results are as follows: (addon-sdk-1.17)me

Intercept download link click and prevent default download dialog

狂风中的少年 提交于 2019-12-25 02:59:28
问题 We have built a download manager desktop application for windows. Now we want to add a feature that intercepts download links and adds them to the application. We think we should write an addon for each browser starting from Firefox. To intercepts download links for a download manager, is writing addons the best choice? How can we do that? Things we've tried so far: - Using Downloads.jsm to observe new downloads, then cancel them => We don't want the user to interact with Firefox's download