firefox-addon-restartless

removeEventListener in bootstrapped addon not working when addon disabled

狂风中的少年 提交于 2019-12-12 01:58:41
问题 I have noticed that after disabling a bootstrapped add-on, the removeEventListener does not seem to remove the listener and I can't work out the reason. let contextMenu = window.document.getElementById('contentAreaContextMenu'); if (contextMenu) { contextMenu.addEventListener('popupshowing', this.contextPopupShowing.bind(this), false); // added this to make sure they refer to the same function console.log(this.contextPopupShowing.toString()); } And then on disabling the addon console.log(this

Simple storage not persisting data between sessions

▼魔方 西西 提交于 2019-12-11 08:58:06
问题 I'm trying to use the simplestorage from my extension, but I can't retrieve values between browser sessions. Here's the thing: From my main code, I created a value this way: var ss = require("sdk/simple-storage"); ss.storage.foo = [{id:"bar1", properties:{a:"aaa", b:"bbb"}}] console.log(ss.storage.foo); This is ok, I coud see the object through the log. But then I closed the browser, commented the "foo definition" (line 2) and the console log was " undefined ". I know cfx run by default uses

How to develop legacy Firefox add-ons in the future?

╄→гoц情女王★ 提交于 2019-12-11 02:37:54
问题 Firefox is moving towards the WebExtensions standard which promises improvements in stability, cross-browser compatibility, and more security. At the same time they're gradually dropping support for legacy add-ons (bootstrapped extensions, add-on SDK, etc.). Unfortunately, the WebExtension APIs are much less powerful than legacy add-ons which by contrast have full control over the browser. I fully understand the motivation for the switch, but the features my add-on provides just can't

XMLHttpRequest POST and open target page in new window/tab

落花浮王杯 提交于 2019-12-09 19:25:18
问题 How do you emulate Form's 'POST' action with target="_blank" in XMLHttpRequest ? (ie post data and open target page in a new tab) 回答1: gBrowser offers this functionality right out of the box. var dataStream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci.nsIStringInputStream); dataStream.data = "foo=bar&alpha=beta"; // make sure the values are properly encoded with encodeURIComponent var postStream = Cc["@mozilla.org/network/mime-input-stream;1"].createInstance(Ci

In a Firefox non-overlay extension, how to add text to a browser toolbar icon?

我与影子孤独终老i 提交于 2019-12-08 09:50:56
问题 How do you add text to your add-on's browser toolbar button? I'm interested in something exactly like how the download manager button shows the " 2h " text above a progress bar, when 2 hours is remaining to download the requested file(s). Is it even possible to do this without resorting to having a whole lot of pre-made images including the text? 回答1: When you have a known working example, one way to figure out how this type of thing is implemented in the DOM (the entire browser window is a

Is it possible to get the window object from the event in handleEvent?

自闭症网瘾萝莉.ら 提交于 2019-12-08 02:56:08
问题 As in the question... how to get the window object from an event fired in the window scope for example: handleEvent: function(event) { // is window object available here and can we get it from event } I can get the window object from other APIs. I was wondering if it was possible to get it from the fired event . Reference: handleEvent Code Snippet using handleEvent 回答1: I found out the answer ... any of these will get the window object from the event event.view event.view event.target

How do you convert a local URI to path?

给你一囗甜甜゛ 提交于 2019-12-07 19:46:26
问题 How do you convert a local (filesystem) URI to path? It can be done with nsIIOService + newURI() + QueryInterface(Components.interfaces.nsIFileURL) + file.path but that seems like a long way. Is there a shorter way? Here is an example code: var aFileURL = 'file:///C:/path-to-local-file/root.png'; var ios = Components.classes["@mozilla.org/network/io-service;1"] .getService(Components.interfaces.nsIIOService); var url = ios.newURI(aFileURL, null, null); // url is a nsIURI // file is a nsIFile

XMLHttpRequest POST and open target page in new window/tab

霸气de小男生 提交于 2019-12-04 13:00:59
How do you emulate Form's 'POST' action with target="_blank" in XMLHttpRequest ? (ie post data and open target page in a new tab) gBrowser offers this functionality right out of the box. var dataStream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci.nsIStringInputStream); dataStream.data = "foo=bar&alpha=beta"; // make sure the values are properly encoded with encodeURIComponent var postStream = Cc["@mozilla.org/network/mime-input-stream;1"].createInstance(Ci.nsIMIMEInputStream); postStream.addHeader("Content-Type", "application/x-www-form-urlencoded"); postStream

How to pass formData to postData in loadOneTab?

。_饼干妹妹 提交于 2019-12-02 17:38:28
问题 I have a formData object and would like to pass it to loadOneTab() Example: var formData = Components.classes['@mozilla.org/files/formdata;1'] .createInstance(Components.interfaces.nsIDOMFormData); formData.append('Content-Type', 'multipart/form-data'); formData.append('filename', ''); formData.append('image_url', URL); How can I pass above object to postData window.gBrowser.loadOneTab('https://www.example.com/', {inBackground: false, postData: postStream}); 回答1: I already kinda answered this

How to pass formData to postData in loadOneTab?

老子叫甜甜 提交于 2019-12-02 10:39:36
I have a formData object and would like to pass it to loadOneTab() Example: var formData = Components.classes['@mozilla.org/files/formdata;1'] .createInstance(Components.interfaces.nsIDOMFormData); formData.append('Content-Type', 'multipart/form-data'); formData.append('filename', ''); formData.append('image_url', URL); How can I pass above object to postData window.gBrowser.loadOneTab('https://www.example.com/', {inBackground: false, postData: postStream}); nmaier I already kinda answered this as part of your last question . Unfortunately we cannot use FormData here, as there is currently no