How to check if Javascript is activated from Firefox extension? - javascript

I haven't found any info on that. I basically need to know from a Firefox extension if the browser has javascript enabled. Is that possible?
I am totally new to programming FF extensions -- actually this is my first one and among the requirements is this one I haven't been able to figure out.

Via #ChristianSonne: You could try
require("preferences-service").get("javascript.enabled")
in Jetpack-style addons.

Related

Attach to Chrome instance and run JavaScript in a tab

I'd like to connect to an existing instance of Google Chrome and run some JavaScript to find a specific tab and execute some code in it.
I remember reading something about how to do this a long time ago. Can anybody offer any guidance?
Edit: I've done this before using Firefox, and I just remembered I used the MozRepl extension there.
After remembering more about how I did this in the past with Firefox, it looks like the ChromeRepl extension may be the way to go here.

Open a Internet explorer/Firefox etc window with Chrome

I'm building a smaller Web Builder with Javascript and I want the user to be available to preview their page in all the major browsers. Because that the tool only is available for Chrome I need them to get the chance to open a Internet explorer window with the same information, and the same for Firefox and Opera and Safari... Is there a way to do so, in Javascript?
P.S. The information that should appear on in the window is stored in a variable.
If JS can call firefox.exe, it could also call nasty_trojan.exe. The best you can do is generate a custom link server-side, and say "paste this link into your other browsers.
Unless you'd like to be really fancy, in which case you need to render the pages server-side, ala http://browsershots.org/.
There's a chance it could be done if you wrote it as a chrome extension, because those have some measure of trust, but the JS on a page stays very much inside its sandbox.
This doesn't belong on the answers, but I did not see how to comment (I am new, sorry!). This may help. It seems you may need to use a java applet, at least, I'm seeing that in a few places. Hope I've helped!

firefox disable/enable add-on in a specific page

I'm programming a system to work with in firefox, based on high end javascript.
The users sometimes uses add-ons that conflict with the system.
Is there a way i can control from my web-site to disable or enable specific firefox add-ons in a page?
Thanks.
You can do it inside an add-on, prior to Firefox 4 there was the nsIExtensionManager interface, starting with Firefox 4 there is the AddonManager object
I would say no, I wouldn't want sites I browse doing anything to my browser add-ons unless I said they could.
With things like Firebug you CAN detect them though and warn the user, then it's down to them to turn them off and not you.
And here's another thought...imagine me turning off your Adblock because my site doesn't work well with it ;)

Finding the currently logged in user from a Firefox extension

I'm writing a Firefox extension that needs to know what the username of the currently logged in user is in Windows, Mac, or Linux. So if I'm logged into my machine as "brh", it'll return "brh". Any idea how to do that from extension JavaScript?
Firefox extensions play by different rules to normal JavaScript running in the page: finding the current user is absolutely possible.
Open your Error Console (in Tools) and enter this:
Components.classes["#mozilla.org/process/environment;1"].getService(Components.interfaces.nsIEnvironment).get('USER')
The environment variables Firefox was started with are available through that NsIEnvironment XPCOM component.
You may have to customise this per platform. If all else fails, you might be able to create an NsIFile in ~ then look at its .path; I'm not sure if shell expressions are honoured there, though...
The flagged correct answer works fine. I use this in our extension on Firefox 38. I also use events so that the page can communicate with the extension and retrieve windows properties from the extension.
getWindowsProperty: function(prop){
return Components.classes["#mozilla.org/process/environment;1"].getService(Components.interfaces.nsIEnvironment).get(prop);
},
Don't think that's possible, seems like it would be a security hole if it were.
Yea, not possible... Javascript runs in a secure enviroment, and all FF extensions are javascript so you wont be able to be doing much interaction with the OS... but ill stick around to see if someone knows a way(it would be VERY cool...)

Hide google Toolbar by javascript

Is there a way to hide the google toolbar in my browser programmable?
You haven't said which browser you are using so I'm going to assume Internet Explorer* and answer No.
If JavaScript on a web page could manipulate the browser, it would be a serious security hole and could create a lot of confusion for users.
So no... for a good reason: Security.
*. If you were using Firefox, and were talking about JavaScript within an extension to manipulate and theme the window chrome then this would be a different story.
I really think that it is imposible to do that with javascript. This is because javascript is designed to control the behaviour of the site. And the browser is not part of the site.
Of course maby you are talking about some other Google toolbar then the plugin in the browser.
As far as I know, you cannot access these parts of the browser due to security issues. But you can load new browser windows without toolbars as such. I don't know exactly how (hopefully other users will help yout out), but maybe start here: http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20782379.html
(PS: I know, it's experts-exchange, but I'm not going to copy someone elses work, even if it's posted on EE).

Categories

Resources