Override/embed addon SDK in a Firefox extension to modify panel.js - javascript

I use the Addon SDK to display a Panel. It's working fine, but I would like to set the noautohide property to true, so the panel will not closed automatically when user clicks outside the panel.
I managed to access to the panel object using "chrome" authority but I am afraid of the red mark "experimental" ;-)
So I would like to edit panel/utils to expose the noautohide property. Is it possible to "override" or "embed" my edited file in the extension package?

Unfortunately, there is no supported way of doing this (that I know). Searching the SDK sources for noautohide without any results seems to confirm this.
Personally, I'd use the require("chrome")-and-get-the-XUL-element workaround for now (but keep in mind that there could be more than a single browser window), or just not implement it at all.
I would advice against patching the SDK and/or "embedding" a patched panel library.
The former would require to use a bundled SDK instead of the built-in SDK and seeing all the changes that go into each Firefox release, you'd likely have to re-package your XPI with every major Firefox update. Also you're not allowed to host add-on on AMO that bundle a patched SDK.
The latter option of "embedding" just the panel lib has the same maintenance problems. Also, it isn't exactly easy to extract/clone the just the panel library from the SDK... At the very least you'd have to clone sdk/panel.js and sdk/panel/*.js maybe even more.
It might be helpful if you filed a feature request.

Rather than patch it what you can do is as addEventListener for popuphiding and do event.stopPropagation(); and event.preventDefault();. Then just add a close button that on click removes that listener and then hides the panel. I couldn't get arouund the noauthohide any other way:
Avoid panel to autoHide in Firefox extension

Related

Open HTML link with IE11 [duplicate]

I have designed a website using Firefox and am now looking to integrate a softphone into the webpage, but unfortunately it is made with ActiveX, so Firefox won't support it.
I have tried opening my page in IE9, and it looks a mess because I've used CSS3 for a lot of it and haven't coded it for different browsers because we will only be using Firefox within the office.
Is there a way that I can tell my page in Firefox to specifically open a new page in Internet Explorer and just have the softphone in there? Or is there a way to get ActiveX running in Firefox with a plugin or something?
You can open a link in Microsoft Edge from any browser by adding microsoft-edge: in front of the url in the HREF.
EDGE (works)
I don't know how to get it to work in other browsers though. My team and I spent quite a bit of time on it and couldn't find a raw HTML/JavaScript solution.
I don't think you can open a IE window from firefox, but you can easily build a firefox plugin based on your activex using http://code.google.com/p/ff-activex-host/
It really depends on your exact situation.
If you are targeting multiple users outside a corporate network this is hardly possible to achieve. However, if you are targeting your company's network it's possible to do this using custom protocol.
Your link then would look like: ie://opens_in_ie.com
You'll have to make changes to registry of target computers though. More info about custom protocols is available here: http://msdn.microsoft.com/en-us/library/aa767914%28v=vs.85%29.aspx
In most cases, system administrator can do this remotely.
IETab V2 will let you open a tab within Firefox that runs the IE engine.
Once installed, you can force a link to open with IE by formatting the URL or bookmark like this:
chrome://ietab2/content/reloaded.html?url=http://domain.com
It's somewhat specific, but I created an internal site at work, and I wanted to link to another internal site that only works in IE. To do this, I created/defined my own application protocol in the registry. Then I added to my links the protocol header. This is similar to what apple does when you click a link and it opens iTunes. The downside to this approach, however, is that users will have to install the registry modification for it to work... like I said, it's really a solution for a very specific scenario.
Same answer as from chuck wallace
If you want to start from for example in Internet Explorer, go to C:\Program Files\Internet Explorer\iexplore.exe and create a shortcut to the Desktop.
When you check the properties from this created shortcut, you will see the Target: C:\Program Files\Internet Explorer\iexplore.exe.
Now you can place the shortcut from the website, behind the Target. It will show something like this: C:\Program Files\Internet Explorer\iexplore.exe www.nu.nl. Or this C:\Program Files\Internet Explorer\iexplore.exe https://stackoverflow.com.
This way it opens IE first and then the website.

Turn bookmarklet into Firefox extension?

I have developed a very powerful and complicated bookmarklet, but it's starting to bump into the edges of the bookmarklet format. I'm considering turning it into a browser extension. For Chrome, I found this tool that makes it easy to get started. I'll need to tweak the outputs a bit, but it's fairly simple.
I'm wondering if there's something similar for Firefox. I want an extension that adds a button to the browser, and when you click it, it runs a script on the page. Can anyone point me to a tutorial, or the related part of the documentation?
Bookmarklets are very simple. The WebExtension API is not good if you want to use the addon right away.
The SDK is guaranteed to work right now, and the level of features which you will use from the SDK for a bookmarklet will continue to work in the future.
It's quite easy. What you want to do is follow this guide: https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Getting_Started_%28jpm%29
Do the prerequisites (install node [which installs npm]) should take just a few minutes.
Then when you get to the Implementing the add-on section of that guide. Don't paste what they say, instead paste this:
var data = require("sdk/self").data;
var pageMod = require("sdk/page-mod");
pageMod.PageMod({
include: "*.mozilla.org",
contentScriptFile: [data.url("jquery.js"),
data.url("my-script.js")]
});
Modify the include to match the website you want to target.
Then create a folder next to your index.js file, call it data. Inside, create my-script.js and paste your bookmarklet. If you need jquery then add that in there as well. If you don't, then remove jquery from the contentScriptFile line in the snippet i pasted above.
Then type in npm jpm xpi in command line (as thats how you use jpm).
To test - Make sure to go about:config and set xpinstall.signatures.required to false, as signing is required for Firefox now. Then drag that xpi to your Firefox.
Then when ready, upload that XPI to addons.mozilla.org :)
Starting at version 42 (current stable version), Firefox includes support for WebExtensions, ie the same API as Chrome Extensions, so you can luckily use the same tool.
Take into account that it's work in progress and it's not 100% ported, so please read the docs about the state of it.
The current Addon SDK will be deprecated in the future in favor of WebExtensions, so I think you should give WebExtensions a try, even more when it allows you to only have to maintain one code base.

How to detect and/or block browser extensions that mess up my website?

More and more of our users (I manage a french blogging platform) are complaining about bugs on our interface. In 90% of cases, the problem comes from an extension that is installed on the user's browser. Users often don't even know that they have these extensions.
For example, there is Avast that removes sharing buttons (Twitter, FB), and some extensions like Pricepeep, Slick Saving, Deaply Shopping, VideoFileDownload or Pricora that totally mess up our interface.
The problem is that users believe that it is our fault and then quit without further investigation :-(
Do you have a miraculous solution to block or detect some or all of bad browser extensions? Thanks in advance!
If you think it is worth the trouble, you could implement your own extension (and offer the user to install it to get rid of UI-breaking).
In this extension you should use the chrome.management API to:
Get all installed and enabled extensions (using method getAll()).
Detect the ones you know are "harmful" to your UI (e.g. filter the installed and enabled extentions against a list of known-to-cause-trouble extension IDs or names).
Inform the user about the situation.
Offer to disable or even uninstall the problematic extensions.
(I haven't tested it but supposedly you could disable or uninstall an extension even without the user's intervention, but -even if doable- it is hardly a good practise.)
I dont think you can block the extensions, however you could detect that your buttons are getting hidden and if so show a message explaining the user that they probably have such and such extension installed, with instructions on how to remove them.
Will cover most cases.

What's a simple way in Google Chrome to insert Javascript into sites?

I would like to be able to add custom snippets of javascript to any site that matches a regex. This is mostly because of sites that I use daily because of specialized content, but which have a poor design. I want to be able to do something like:
Visit site See that sidebar overwrites content
Whip out developer tools, find div id for sidebar
Edit a snippet of javascript which is executed on document.ready for this domain:
$('#sidebar-right').remove();
A bit of searching for user scripts tells me that I need to be writing a Chrome extension, which seems unfortunate and overkill. Is there not an easier way, or an extension which is nothing but a javascript editor that assigns snippets to domains? I'd really like to be able to edit in Chrome itself, or at least have a file that I can just leave open in MacVim all the time. An extension requires unloading/installing to update as far as I can tell.
If I just had one big javascript file, that would be fine. I'd just wrap my customizations in domain checks.
Bonus love if I can write in CoffeeScript.
The answer is to use the Tampermonkey chrome extension.
https://chrome.google.com/webstore/detail/dhdgffkkebhmkfjojejmpbldmpobfkfo
Why not dotjs http://defunkt.io/dotjs/ ? It's local, you can version it with git, you can easily take it to another computer...
Another alternative that neatly solves the problem is Custom JavaScript for websites. You just need to install the extension, which takes around 2 seconds, and then you can immediately start typing your custom JavaScript for the specified website.
The extension automatically recognizes the current website, so all you need to do is write your code and click on Save. You can also easily import jQuery or your external scripts for convenience.
Custom JavaScript for Websites 2 is an alternative to Custom JavaScript for Websites, with some bug fixes and sync scripts across devices feature.
Snippets are available directly in Chrome Devtools
https://developers.google.com/web/tools/chrome-devtools/javascript/snippets
Witchcraft is another Google Chrome extension for loading custom Javascript and CSS, and it is supposedly for more avanced users. The older dotjs project repository lists Witchcraft as its successor.
What you're looking for is Greasemonkey. But wait, Greasemonkey is for Firefox only, right? Turns out, you can install Greasemonkey user-scripts as native Chrome add-ons. Just go to userscripts.org and hit the Install button on one of them, and Chrome will automatically convert it into a native add-on. Then, write your own and install it using Chrome.
Note: This only works in Chrome 4.0.

Can you get a list of Firefox add-ons programmatically

I spent a fair amount of time trying to determine why my view of a site didn't match a clients, after looking at the cache etc. we determined the problem to be with one of the add-ons (Adblock Plus in this particular case). It would have been much simpler if we could have had an easy way to query what add-ons were installed, and ideally active. Is there anyway to generate a list programmatically perhaps with JavaScript?
No, you can't do this with user/page JavaScript. I imagine it would be a security risk, if you could.
But there is an add-on you can install that will generate a printable, copyable list of installed extensions/Add-ons.
Check out: "Extension List Dumper".
You cannot get a complete list just by using Javascript, but some Addons allow a check anyway.
accessing the chrome://-protocol was considered a security risk and
therefore has been disabled. Nonetheless you can still accomplish to detect
an extension with the image-load trick. Why? Because extension
developers may mark their extension as web-accessible setting the
property “contentaccessible=yes” inside the chrome.manifest file of
the extension. This is e.g. the case for the two famous plugins
Firebug and Web Developer Toolbar
source: http://webdevwonders.com/detecting-firefox-add-ons/

Categories