firefox-addon-sdk

Evaluating an XPath expression in XML

心已入冬 提交于 2019-12-10 16:08:42
问题 When using the Add-on SDK to create a Firefox add-on, how do you process an XML file? Evaluate with XPath throws an error: XPathResult is not defined I am trying to process this XML data with this code: var iterator = xmlDoc.evaluate('//stream', xmlDoc, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null); 回答1: Yes, a lot of global classes available in the window context aren't there in SDK modules which are sandboxes. You can access this constant via nsIDOMXPathResult interface: var {Ci} =

Detecting navigation in FF add ons

与世无争的帅哥 提交于 2019-12-10 15:56:24
问题 I am porting a Chrome extension to FF using 'FF Addon SDK'. In the background script (main.js) file, I need to use the FF equivalent of... chrome.webNavigation.onBeforeNavigate.addListener() and chrome.tabs.onUpdated.addListener() I noticed that require("sdk/tabs").on only has open, close, finish, etc., but nothing to do with the navigation. I see a few solutions that use Page-Mod or show the solution for the old XUL way of developing FF Extensions. I am specifically looking for an FF Addon

Icon not showing in firefox add-on manager

半世苍凉 提交于 2019-12-10 14:51:55
问题 I have a new Firefox add-on with the following directory structure: / package.json data/ icons/ icon48.png In my package.json file I have this: "icon": "data/icons/icon48.png", (among other things). When I run jpm run as recommended by the Firefox add-on docs, the extension loads but the icon is not visible in the add-on manager. Any idea what I'm missing? I have been referencing this page: https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/package_json#icon, but no luck. Thanks! 回答1:

How to use Flowplayer functions in a content script?

僤鯓⒐⒋嵵緔 提交于 2019-12-10 12:50:28
问题 I am trying to write a Firefox add-on for personal use and to learn a bit more about both JavaScript and the Firefox Add-on SDK. The add-on should open a vivo.sx URL and then automatically start the player, but I have 2 issues. I hope you guys can help me. The relevant add-on-code: function vivoplay() { pageMod.PageMod({ include: "https://vivo.sx/*", contentScriptFile: "./vivoplay.js", onAttach: play }); function play(worker) //Fires 2 Times { console.log("Timeout"); tmr.setTimeout(sendplay,

How to access a SQLite database inside the data directory in add on builder

我与影子孤独终老i 提交于 2019-12-10 11:53:57
问题 Is there any way to access a SQLite database inside the Data directory in the add-on builder using add-on sdk v1.5? this is the code that i am using: var {Cc, Ci, Cu} = require("chrome"); var data = require('self').data; // This is an active module of the pankajsingh5k Add-on exports.main = function() { var {Services} = Cu.import("resource://gre/modules/Services.jsm"); var {FileUtils} = Cu.import("resource://gre/modules/FileUtils.jsm"); var file = FileUtils.getFile("Desk", "Helper.sqlite");

cannot make http request javascript ns error failure

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 11:39:41
问题 I started learning addon development using addon-sdk. I'm writing a small addon script which display IP address of current webpage. I used a website which provides JSON data values. http://dazzlepod.com/ip/stackoverflow.com.json Now the problem is when I make XMLHttp request to get JSON values it shows 0x80004005 (NS_ERROR_FAILURE) Message: [Exception... "Failure" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: .... ...... :: httpGet :: line 30" data: no] Here's my ScriptCode function

Prevent the closing of a tab with firefox addon sdk API

强颜欢笑 提交于 2019-12-10 11:16:22
问题 I am looking for a way to prevent the closing of a tab using the firefox addon sdk. Is there a way to achieve that? 回答1: Ok man here is what you want. The previous version was to see if i could get onbeforeunload to trigger only when tab closed, but i couldnt figure that out. Here's how to do it: We override the removeTab function. Following the guidlines here: MDN :: Overriding/Extending/Amending existing functions - Alternative: Replace + Function.apply() // Keep a reference to the original

difference between creating firefox addon using sdk and normal method

旧巷老猫 提交于 2019-12-10 10:57:24
问题 I have just started creating firefox add-on. So I have downloaded sdk and successfully created sample add-on, and its directories are like this data doc main.md lib main.js test test-main.js package.json readme.md But When I search for how to develop add-on for firefox from scratch it is showing some like this https://blog.mozilla.org/addons/2009/01/28/how-to-develop-a-firefox-extension/ Directory structure http://blog.mozilla.org/addons/files/2009/01/extension-structure.png Can any one help

Access the Add-on SDK from within a traditional XUL-based add-on?

孤街醉人 提交于 2019-12-10 10:16:49
问题 I have a large and complex XUL-based addon for which I need to use a few functions from the Add-on SDK. Is this possible? If so, does anyone have working sample code, preferably using the page-worker module? 回答1: The following is the way devtools does it, but certain modules will choke (the obvious candidate being self ). I think you will have better luck with low-level modules. let {Loader} = Cu.import("resource://gre/modules/commonjs/toolkit/loader.js", {}); let loader = new Loader.Loader({

How to add a Progress Listener to a tab object from Addon SDK

拟墨画扇 提交于 2019-12-10 09:55:55
问题 I'd like to get URL change notification (not load ones). There is an API, but I don't understand how to use in context of Addon SDK, which treats tabs in its own way. How to install a listener to an SDK tab? How to convert nsiDOMWindow from a progress object to SDK tab? Related: How to get Tab from nsIDOMWindow? 回答1: To install a listener, convert SDK tab to its raw (old) representation using viewFor. Backward conversion is possible with modelFor and getTabForContentWindow. const tabs =