Display options.xul programmatically - firefox-addon

I have an xul overlay based Firefox Add-on that works. It has inline options defined in content/options.xul and they display/function correctly when the user goes to Firefox->Add-ons->Extensions->{The Name of My Extension}->Options
The question, can I a create a button on my Add-on that will launch my options either by taking the user to Firefox->Add-ons->Extensions->{The Name of My Extension}->Options with one click or by launching a dialog based on options.xul?
Right now I am maintaining a separate options.html and options.js that gets and sets the same settings that options.xul handles when the user navigates there via the Firefox button but I would much rather dump options.html and options.js and only maintain my main.js and options.xul.
Any comments or code examples will be greatly appreciated.

This is easiest to do via a global function BrowserOpenAddonsMgr() defined in the browser window, like this:
BrowserOpenAddonsMgr("addons://detail/" + encodeURIComponent(addonID));
This function takes care of focusing the existing add-ons tab if there is one or opening a new tab. It will not scroll down to the options however which is an issue if the add-on has a lengthy description. Starting with Firefox 12 this can be solved by adding "/preferences" to the view identifier:
BrowserOpenAddonsMgr("addons://detail/" + encodeURIComponent(addonID) + "/preferences");
With older Firefox versions you are out of luck (and you shouldn't use this suffix there, it won't work). The other issue is that there can be a lengthy "loading" phase where the add-ons manager fetches metadata for all extensions.

Related

Umbraco - editing preview window sidebar options

I have a project which is using Umbraco v7.7.9 installed with nuget.
I was wondering if it is possible to change the buttons displayed in the sidebar section when a user selects to preview a content node. Particularly I want to remove the option that allows the user to close the preview.
The reason I want to hide this option is because some of the content the backoffice users will be previewing will not actually be published yet so clicking the close preview button causes an error.
I first asked this question on the Umbraco forums but haven't received a response yet, here is the link to the question: https://our.umbraco.org/forum/extending-umbraco-and-using-the-api/90878-editing-preview-window-sidebar-options
Thank you in advance.
Currently no - it would not be possible without doing hacks in the Core that would be overwritten when you upgrade your site (unless you manually merge your changes in when updating).
If you however don't mind doing that - the file used for the preview function is /umbraco/preview/index.html. You should look for the element with an exitPreview() click handler attached to it.
In later versions (7.10+) this modification will have to be done in /umbraco/Views/Preview/Index.cshtml instead, as these static files will be changed to MVC actions.

Firefox SDK: simpre-prefs: is it possible to change the label of the control-button?

I am writing code that capture hotkey after user press control-button in preferences of addon - I want to change the label when user push the button and change again when user push some keys (to display the new hotkey). Official documentation about simple-prefs not mention that I can change something visual in loaded preferences view and in debug I looked into object prefs and saw that my preferences is just a strings - only the values and types.
I do not think you can unless you hack the preferences page. I saw your other question and the example add-on from the answer. It's not using simple-prefs and I don't think it's a great user experience either. I have the same problem and was thinking to use a control button to bring up a panel on which you can listen to the keystrokes and print them there. A panel is all html so you can do whatever you like.

how to open many tabs in chromium but unload/disable inactive/notCurrent ones, releasing memory and cpu?

So I have 50 tabs opened on chromium, but that is using too much memory and some of the CPU.
How can I have all those concurrent researches I am doing opened but not clog my machine?
I think there should have a way that only the active tab is loaded in memory and running, and all the others should stay closed/unloaded from memory, until I want to look at them...
Any extension can do something like that?
EDIT: tabs outliner seems to do the trick as #Danny Beckett said, but I still wonder if the non active tabs could be unloaded (automatically); may be something like keep only the last newest 10 tabs opened/loaded, and auto-close the older ones; may be tabs outliner can have that feature in the future, just need find a proper way to ask its developer... any other tips?
EDIT: here a link to the idea: auto close old tabs, go there and upvote if you like it!
The Tabs Outliner extension does exactly what you're asking.
Type command "chrome://kill" (or "chrome:kill") in the address URL bar (like a http:// URL but with chrome:// first) to individually release tabs from memory.
Otherwise for a GUI, in the standard Chrome Task Manager (type Shift-Esc [or go to menu "More Tools..." then "Task Manager"]), then just "click-to-kill" the tabs you want to release from memory.
That language command is painful/difficult/violent/triggering but will not crash your computer or cause harm, that is the actual English command.
(I too use and love the Tabs Outliner suggested before, but still sometimes type the command.
Pro Tip: Make "chrome://kill" a convenient link in your Bookmark Bar.
Other benefits to the command version, are that if you reload the page, Chrome with chrome:kill still has it cached, so page position and form fields can be restored automatically. However with Tabs Outliner it wil not remember the reloaded page contents, there is not any cache.)
You can right click on Chrome title bar and choose "Task Manager"
Task Manager path
Then you can choose for which tab or window you want to end process which will essentially unload tabs and windows from the memory.
Task Manager screenshot
You can close everything except for the main Chrome process indicated by green arrow in the screenshot above. Ending this process would be the same as closing all Chrome instances altogether.

Cross browser addons

This has been discussed in a few threads - but none gave any real answers.
I need to develop a very simple browser addon which just has a single button, and can run a javascript function when pressed. It must sit as a toolbar or similair.
Now, is there an easy way to develop once for Chrome, IE, and FF?
Only supporting the latest version of each browser is fine too.
Thanks
If you mean a javascript (not particular to a certain browser e.g showing the history) you can run it like this (pasting it into the url bar):
javascript:alert("Hello!");
You can make a link with the href going to your script, then tell your users to drag the link into their bookmarks bar. E.g
Link text

Google Chrome Extension: Print the page silently

I'm developing an internal Google Chrome Extension that needs a way to initiate print the current page to the printer. I do not want the default Print dialog to come up (so, javascript:window.print() is out of question).
As far as I understand, this is not possible just with the JS + HTML plug-in, so I'm also open to using the NPAPI plugin also (with a dummy mime-type). And I'm concerned for Windows platform only.
I'm also open for various hacks / workarounds if possible, though a standard solution would be nice.
If you think this is not possible, let me know if you know any feature request logged for it?
Any suggestions/clarifications are welcome..
In chrome (v18+) we have the --kiosk --kiosk-printing switches. One can print automatically to default printer without print confirmation.
You can see it from this video http://www.youtube.com/watch?v=D6UHjuvI7IE
Since NPAPI allows you to create native C++ plugins that you can interact with through an object tag (which you can use from an extension), that would probably be the way to do it.
The tricky bit is that I don't know of a good way to get the bits for printing the page. The only person I know of who has done something similar to this actually got the window handle for the browser (available through NPAPI) and scraped the bits off of it to print that way, but that won't take into account print stylesheets or anything. You could also try using automation events to try to control the print dialog, but I have no idea if that would work or not.
By design, the browsers try not to let you do something like this, as it could open some serious vulnerabilities if any website could just start printing things to your printer without confirmation...
Anyway, if you find a way to do it with C++ you can use FireBreath to ease the creation of the NPAPI plugin.
There are various extensions that take snapshots of the current web page (for example, this one); you could adapt one to send the image to a printer via an NPAPI plugin.
I've recently been looking for a similar ability, and it seems like it would be quite possible using Chrome's new native messaging api.
https://developer.chrome.com/extensions/nativeMessaging
There are plenty of examples of this with C#, but here is one quick example of troubleshooting Chrome native messaging with a basic C# application
Native messaging from chrome extension to native host written in C#
I realize this may be a day late and a dollar short, but in case anyone else comes across this question, this is the solution that worked for me. From inside a C# app, you can directly print to installed printers using the PrintDocument class. If you figured out a way to get the page image, this would be far easier than using firebreath or NPAPI.
Disable print preview in Google Chrome on Mac
Quit Google Chrome
Launch Terminal on your Mac. (Search “Terminal” using the Search box)
Type defaults write com.google.Chrome DisablePrintPreview -bool true
Close Terminal and open Google Chrome
Disable print preview in Google Chrome on Windows
Close Google Chrome
From your desktop, right click Google Chrome
Click Properties
In the dialog box, add ‘ –disable-print-preview‘ at the end of the Target field sans the apostrophe (make sure to include the space before –)
Click Apply
Disable print preview in Firefox on Mac
In the address bar type “about:config” and press Enter.
Right click on the page, hover over ‘New’ and click on ‘Boolean’
Type ‘print.always_print_silent’ as the preference name and click ‘OK’
Click on ‘true’ and click ‘OK’.
Close the about:config window.
Disable print preview in Firefox on Windows
In the address bar type “about:config” and press Enter.
Right click on the page, hover over ‘New’ and click on ‘Boolean’ Type
‘print.always_print_silent‘ as the preference name and click ‘OK’
Click on ‘true’ and click ‘OK’.
Close the about:config window.
https://support.dryfta.com/how-to-disable-print-preview-in-chrome-firefox-on-windows-mac/

Resources