firefox-addon-sdk

Mozilla Add-on development: Accessing LAST USED or LAST CHANGED fields in password manger

喜夏-厌秋 提交于 2019-12-11 10:06:17
问题 My add-on needs to access stored credentials. In this I want to get the credentials that was changed or used recently. I see that I have LAST USED and LAST CHANGED fields but how do I access those fields in my javascript? I searched and also tried ( https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/passwords ) but I couldn't get anything. 回答1: This is how to get a list of all the currently stored login informations: var lm = Cc["@mozilla.org/login-manager;1"].getService(Ci

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

Is it possible to modify a firefox addon written using XUL with an addon written using the Addon SDK

梦想与她 提交于 2019-12-11 07:51:50
问题 I want to write an addon which enhances an existing addon (e.g., adding an options dialog). I do not want to modify the original addon's code directly. The original addon I wish is written using XUL. Does this mean I have to write my addon using XUL as well? Or can I use the newer Addon SDK? Thanks! 回答1: Yes, it is possible to extend other add-ons. There are actually quite a few add-ons that either extend or interact with other add-ons, for example Element Hiding Helper extending Adblock Plus

How to pass a value between browser tabs?

一曲冷凌霜 提交于 2019-12-11 07:36:10
问题 I am trying to pass a value from one tab to another. I tried sessionStorage and clipboard, but no luck so far. Here is the demo, and the code as well: https://builder.addons.mozilla.org/package/154290/latest/ What it tries to do is get the selected text, and pass it to the opened tab: // Create a new context menu item. var menuItem = contextMenu.Item({ label: "Check with Proofread Bot", context: contextMenu.SelectionContext(), contentScript: 'self.on("click", function () {' + ' var text =

Opening a specific url when a Firefox addon has been installed

痴心易碎 提交于 2019-12-11 06:21:11
问题 I am using the Firefox SDK to create an add-on. I would like a specific webpage to be open once that add-on is successfully installed. I created a module to attempt to do so: var tabs = require("sdk/tabs"); exports.main = function (options, callbacks) { if (options.loadReason === 'install') { tabs.open("https://www.google.com"); } }; exports.onUnload = function (reason) { if (reason === 'uninstall') { tabs.open("https://www.google.com"); } }; I then require this script in my main.js file (

Working with context-menu and port

被刻印的时光 ゝ 提交于 2019-12-11 05:21:52
问题 I read at working with content scripts that one can use port with context-menu, but the following code gives me an error: cm.port is undefined. The same code works with require("panel") when I emit an event, but not with context menu. What am doing wrong? This is main.js const data = require('self').data; var cm = require("context-menu").Item({ label: "asdasd", contentScriptFile: data.url("panel.js") }); cm.port.emit("myEvent", "panel is showing"); this panel.js console.log("entering the

Firefox Add-on SDK: port.on() / port.emit() disrupted by iframe

时光总嘲笑我的痴心妄想 提交于 2019-12-11 05:01:07
问题 I'm working on a firefox addon using the Add-on SDK, in that addon i have a content-script (in a sidebar) communicating with the main addon script using the port.on() and port.emit() as described here in the Add-on SDK documentation. port.on() / port.emit() work fine until i create an iframe in the sidebar (via the sidebar's content script). Once the iframe is added communication between the content-script and the main addon script no longer work via port.emit()/port.on() i've created a

How to load multiple URLS in pageWorker for Firefox add-on SDK?

心不动则不痛 提交于 2019-12-11 03:26:01
问题 Using the following example, I can get First paragraph from one URL i.e, ContentURL . ex - http://www.example.com //main.js var getFirstParagraph = "var paras = document.getElementsByTagName('p');" + "console.log(paras[0].textContent);" pageWorker = require("sdk/page-worker").Page({ contentScript: getFirstParagraph, contentURL: "http://www.example.com" }); I would like to get the first paragraph for multiple site URLs. var urls = ["http://www.example.com", "http://www.example1.com", "http:/

Work with the simple-prefs module and export the values to a script stored in the data folder

安稳与你 提交于 2019-12-11 03:25:45
问题 I'm currently trying to add some preferences to a Firefox add-on. To do so, I'm playing with the new "simple-prefs" module. (Simple-Prefs on the Mozilla Blog) The documentation is not very detailed and I face some problems understanding how I can retrieve the value attached to an option and export it to a JS script present in my data folder. Let's say that I have only one optional setting in my addon, a boolean one, then my packages.json will look like this: { "name": "test", ... "preferences

Mozilla Add-On Execute code on first run

ⅰ亾dé卋堺 提交于 2019-12-11 02:59:48
问题 I am currently building an add on and I wanted to execute specific code on the first run. More specifically I want to click on my add on button, browse through my files and select an executable file. This browsing process should only be done on the first run as I want my button to "remember" to open this specific file after the first run. jetpack.future.import("me"); var buttons = require('sdk/ui/button/action'); var button = buttons.ActionButton({ id: "execute-jar", label: "Download Report",