firefox-addon-sdk

How to reference a JavaScript file in Lib from an HTML file in Data?

混江龙づ霸主 提交于 2019-12-24 04:35:38
问题 I decided to give Mozilla's Add-on Builder a try. My directory structure looks something like this: The problem is that the file popup.html needs to reference stackapi.js . But I have absolutely no clue how to do that. Looking through the Mozilla docs, there seems to be a way to do the opposite: var data = require("self").data; var url_of_popup = data.url("popup.html"); This allows scripts in Lib to access data files in Data. But I need to do the opposite. 回答1: In add-ons built with the Add

Showing more than 1 desktop notification from firefox add-ons

房东的猫 提交于 2019-12-24 01:57:23
问题 I'd like to show a few desktop notifications triggered from my firefox add-on but it seems like you can only show one at a time, from my testing. I am not sure if there is any official way to do this, since I did not find any mentions in the notifications docs https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/notifications, but I'll take a hacky way, too. 回答1: Did you say hacky? var timers = require("sdk/timers"); var {notify} = require("sdk/notifications"); var i=0; var timerId

Firefox addon - icon not showing

那年仲夏 提交于 2019-12-24 00:57:14
问题 I'm trying to write an Addon for Firefox. For this I'm using the Mozilla "Addon-SDK". When i use the "jpm run" function all works well. But as soon as i package it to an xpi and install it, the icon wont show up in the toolbar. This seems to be a bug in the SDK. I have tried various workaround solutions from other blog posts. Editing package.json renaming to "icon" moving to data Moving the icon to root Absolute paths editing the firefox version in rdf debuging Index.js... Here the most

Firefox SDK: correct way to play audio from the url in 2015 year?

无人久伴 提交于 2019-12-24 00:46:43
问题 I want to add ability to my addon to play audio from URL. At MDN I not found information about this. I found this and this and this and this answers - but this is about local file and what the correct answer for 2015 year? 回答1: I have an answer from 2016 ;) That code will not work with Multi-process Firefox (will be released in 2016): var window = require('sdk/window/utils').getMostRecentBrowserWindow(); var audio = new window.Audio('http://example.com/audio.mp3'); vaudio.play(); Because sdk

How to Append to a file in a Firefox add-on?

天大地大妈咪最大 提交于 2019-12-23 22:17:27
问题 var tabs = require("sdk/tabs"); var iofile = require("sdk/io/file"); var widgets = require("sdk/widget"); var selection = require("sdk/selection"); function console_log(text) { console.log(selection.text); } function print(text) { console.log(text); } function dir_object(object_to_parse) { var name = ''; for (name in object_to_parse) { print(name); } } function write_text(filename, text) { var fh = iofile.open(filename, 'w'); var content = fh.read(); dir_object(fh); selected_text = text + "\n

Identify requests coming from PageWorker

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 21:04:03
问题 Is it possible, from within the "http-on-modify-request" event, to identify which requests are coming from a PageWorker object, as opposed to those coming from visible tabs/windows? Note: Because of redirects and subresources, the URL here is NOT the same URL as the pageWorkers contentURL property. require("sdk/system/events").on("http-on-modify-request", function(e) { var httpChannel = e.subject.QueryInterface(Ci.nsIHttpChannel), url = httpChannel.URI.spec, origUrl = httpChannel.originalURI

How to call Firefox printpreview using addon SDK

我只是一个虾纸丫 提交于 2019-12-23 20:23:47
问题 How to call Firefox printpreview using addon SDK. Newest SDK (1.16) not include printultis.js Thank you somuch 回答1: const { getMostRecentBrowserWindow } = require('sdk/window/utils'); var chromewin = getMostRecentBrowserWindow(); chromewin.PrintUtils.printPreview(chromewin.PrintPreviewListener); 回答2: const BROWSER = 'navigator:browser' ; var {Cc, Ci, Cu} = require("chrome"); const WM = Cc['@mozilla.org/appshell/window-mediator;1'].getService(Ci.nsIWindowMediator); function

Firefox SDK: How to make trigger for certain domain

青春壹個敷衍的年華 提交于 2019-12-23 20:10:09
问题 I need to catch requests on sites with URLs *.net and take some actions (stop request and put HTML code from disk, but this I can do). How do I catch these requests? I tried to use progress listeners, but something is wrong: const STATE_START = Ci.nsIWebProgressListener.STATE_START; var myListener = { QueryInterface: XPCOMUtils.generateQI(["nsIWebProgressListener", "nsISupportsWeakReference"]), onStateChange: function(aWebProgress, aRequest, aFlag, aStatus) { if (aFlag & STATE_START) { //

Firefox SDK: How to make trigger for certain domain

一个人想着一个人 提交于 2019-12-23 19:50:16
问题 I need to catch requests on sites with URLs *.net and take some actions (stop request and put HTML code from disk, but this I can do). How do I catch these requests? I tried to use progress listeners, but something is wrong: const STATE_START = Ci.nsIWebProgressListener.STATE_START; var myListener = { QueryInterface: XPCOMUtils.generateQI(["nsIWebProgressListener", "nsISupportsWeakReference"]), onStateChange: function(aWebProgress, aRequest, aFlag, aStatus) { if (aFlag & STATE_START) { //

FF extension - getting xmlhttp.status==0

那年仲夏 提交于 2019-12-23 17:50:30
问题 I'm writing an extension for Firefox and it is using page-mod module to run a JavaScript file containing: function handleServerResponse() { if (xmlHttp.readyState == 4) { if(xmlHttp.status == 200) { //some code } else { alert("Error during AJAX call. Please try again"); } } } var xmlHttp = new XMLHttpRequest(); var txtname = document.getElementById("txtname"); xmlHttp.open("POST","http://localhost:8080/Jelly/GetStuff",true); xmlHttp.onreadystatechange = handleServerResponse; xmlHttp