Do extensions work in other browsers?

Talk about add-ons and extension development.
Jukilum
Posts: 8
Joined: February 18th, 2007, 12:50 pm

Post by Jukilum »

Thanks, You've been a big help. I have one last favor to ask though. Could you write out an example function so that I can be sure I get it right? This is my first project so I'm not very good yet. Would you like to be listed as Philip Chee on the contributors list, or would you prefer a different name?
User avatar
Philip Chee
Posts: 6475
Joined: March 1st, 2005, 3:03 pm
Contact:

Post by Philip Chee »

I found a useful article on the mozine knowledgebase:
http://kb.mozillazine.org/Open_page_using_tab_settings
The following code (I found in the context search extension) might be a bit of an overkill:

Code: Select all

  search : function(aEvent, aDefault) {
 
    if (!aEvent.target.id)
      return;

    var searchUrl = null;
    if (!aDefault) {
      searchUrl = contextsearch.geturl(aEvent.target.id, gContextMenu.searchSelected());
    }
   
    else {
      var defaultEngine = contextsearch.getCharPref("browser.search.defaultengine");
      if (!defaultEngine)
        return;
      searchUrl = contextsearch.geturl(defaultEngine, gContextMenu.searchSelected());
    }

    var loadInBackgroundPref = contextsearch.getBoolPref("browser.tabs.loadInBackground");
    var loadInNewTabPref = contextsearch.getBoolPref("browser.search.opentabforcontextsearch", true);

    var loadInForeground = false;
    var loadInNewTab = false;
   
    if (aEvent.button != undefined) {
      loadInForeground = loadInBackgroundPref ? aEvent.ctrlKey : !aEvent.ctrlKey;
      loadInNewTab = loadInNewTabPref ? !aEvent.shiftKey : aEvent.shiftKey;
    }
   
    else {
      loadInForeground = loadInBackgroundPref ? false : true;
      loadInNewTab = loadInNewTabPref;
    }

    if (!loadInNewTab) {
      openNewWindowWith(searchUrl);
    }   
     
    else {
      var newTab = getBrowser().addTab(searchUrl);
      if (loadInForeground) {
        window.getBrowser().selectedTab = newTab;
      }
    }
    document.getElementById("contentAreaContextMenu").hidePopup();
  },
Would you like to be listed as Philip Chee on the contributors list
None of this code is mine, so you shouldn't list me as a contributor.

Phil
Jukilum
Posts: 8
Joined: February 18th, 2007, 12:50 pm

Post by Jukilum »

Man that is confusing! I'll get the rest figured out from here. I know that none of the code is yours, but you helped me which makes you a contributer.
User avatar
Philip Chee
Posts: 6475
Joined: March 1st, 2005, 3:03 pm
Contact:

Post by Philip Chee »

Jukilum wrote:I know that none of the code is yours, but you helped me which makes you a contributer.
I think I'll still decline. But thanks for the offer anyway.

Phil (has way too many google hits already - 15,400)
old np
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post by old np »

I don't know how well this will perform in something that's not Firefox, but here's a much easier way.
Post Reply