Every time i Google i get the Chrome browser - grr! But I'm trying to understand this:
use another mechanism via the chrome module. See OS.File and/or the MDN File I/O snippets.
Where can i find documentation for this Firefox+Javascript module?
How to Append to a file in a Firefox add-on?
Updated my answer in that other question. I was talking about the SDK chrome module, which is just a way to access Components and with that the XPCOM services and components, so basically what every "old school" XUL add-on gets.
Related
It looks like calling the googleyolo javascript object doesn't work with chrome extensions, probably because it's using an iframe with redirect under the hood, that extensions do not like.
Am I right in thinking chrome extensions are not supported? If yes, does anyone know if there is a plan to support them?
That’s correct. Currently the API expects the calling page to not run inside an extension. We may change this in the future. However you can accomplish what you want to do via a chrome tab launch to a well known page which the extension can inject content scripts into, and notify via chrome cross tab messaging after sign in.
I'm using the Firefox Add-On SDK to port a Chrome extension to Firefox. In Chrome, it's trivial to load third-party libraries like Underscore or Backbone. In my particular case, I'm using jQuery, Underscore and Backbone to define models that communicate with cross-domain REST APIs.
It's unclear to me how you might do something similar in Firefox. From what I can see main.js corresponds directly to Chrome's background pages, but it doesn't appear there's a way to load js files.
Am I missing something?
Add-on SDK supports CommonJS modules sysem, same modules that are also used by nodejs
https://github.com/mozilla/addon-sdk/tree/master/app-extension
Underscore has a support for commonjs module format & there for can be loaded easily
https://github.com/documentcloud/underscore/blob/master/underscore.js#L54-L65
All you need is drop underscore in next to main.js and loaded it as follows:
var _ = require("./underscore")
I do believe backbone can also be loaded in a similar way as people have being using it
on nodejs.
It's won't work for the jQuery though, that's because context where add-on SDK modules
run is different from typical web page context with DOM, which is what jQuery is designed
to work with.
Now if you want to do cross domain requests there SDK comes with a module to do that:
https://addons.mozilla.org/en-US/developers/docs/sdk/latest/packages/addon-kit/request.html
There is also another low level XHR module, that you could use instead:
https://addons.mozilla.org/en-US/developers/docs/sdk/latest/packages/api-utils/xhr.html
So if you just want to write models and talk to REST API it should be pretty trivial, I'm
not sure what's the role of jQuery in your use case. It implies DOM and UI you want to
display. If so there is several modules in SDK that would let you add custom UI for the
firefox and you can probably find useful tutorial on that subject:
https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/tutorials/index.html
I've seen numerous references to browser.js while trying to create a Firefox sidebar. I don't have a good understanding of what this file is though. It has a method toggleSidebar in it. Can I call that method from a web page? Can I call it from a browser extension? Do I need to include browser.js in my extension somehow first? Can I call it from the add-on SDK or is it only available from the old style XUL extensions?
I don't have a good understanding of what this file is though.
It is the code driving the Firefox browser window, lots of code actually.
Can I call that method from a web page?
No. You can use window.sidebar.addPanel() to add a sidebar however.
Can I call it from a browser extension?
Yes.
Do I need to include browser.js in my extension somehow first?
No, it is already included in the browser window.
Can I call it from the add-on SDK or is it only available from the old style XUL extensions?
You can use it from the Add-on SDK as well but you will need to access the browser window directly - either via one of the low-level modules or chrome authority.
It is not uncommon for our intranet web applications to link to publications, documents, or other resources from our shared network file servers.
In the past, we've had little trouble fashioning links such as the following:
file://fileserver1/folderofgoodies/rules.pdf
\\fileserver1\folderofgoodies\rules.pdf
The reason we had no trouble is because everyone in the building uses IE6 or IE7 (very few have IE8). Both styles of URLs worked fine in Microsoft browsers it seems.
But if you try clicking such links in other browsers, specifically Firefox, nothing happens!
On a new intranet web app I'm developing I've been attempting to ensure cross-browser support, but any links to local computer or local network resources seem to be ignored in at least Firefox 3.5.3, though I admit I haven't yet checked other browsers.
Is there any way I can change the way I link to said files so that browsers like Firefox will accept them? I cannot do anything that requires installing scripts, software, extensions, or any other solution on a per-user/per-computer basis.
I realize the suppression of said links is a security thing, but these links would be originating from only trusted local intranet locations, so...
If this is intranet, you can build a little helper server/page/webservice/whatever to which you will link and pass file name as parameter:
http://server/getlocalfile?path=file://fileserver1/folderofgoodies/rules.pdf
And you will benefit from extended security, by the way.
I think your only option is reconfiguring Firefox, but unfortunately you said you can't do that.
You could just map the file server path as a virtual directory into your intranet site and link via http.
Mozilla applications block links to local files. The only way is to install plugin(s) to Firefox. This link describes some of them.
Started working on Firefox add ons, which is done with JavaScript and XUL, and I find myself sorely wanting to use Dojo or someother kind of JavaScript like library, but I can't find one that exists. So I was thinking of starting a library by porting Dojo over to a Firefox add on specific fork. Get rid off the cross browser stuff, use array comprehension and other nice stuff available in Firefox's JavaScript engine. I worry about whether or not there's enough of a userbase who'd take advantage of this, but more than that I guess I'm wondering if there's already something like this? Google finds nothing.
Mozilla Corp developed a JavaScript library for this purpose: FUEL.
it is developed by John Resig the creator of jQuery.
To know how to use jQuery inside FF extension look at this similar question
jQuery, at least, functions perfectly well when embedded in a Firefox addon. I can't quote you names, but I've heard that several popular addons are already using jQuery.
Here's an article discussing using jQuery within XUL and some of the hoops you may need to jump through.
It is fairly common to embed jQuery in firefox extensions.