MozillaZine

[Ext] userChrome.js

Announce and Discuss the Latest Theme and Extension Releases.
JNewbry

User avatar
 
Posts: 321
Joined: April 9th, 2005, 3:56 am
Location: Dallas,TX

Post Posted June 15th, 2006, 7:26 am

Any SeaMonkey users watching this thread? If so... Got any SeaMonkey only code to share?

I recently rebuilt ChromEdit Plus for SeaMonkey to INCLUDE a toolbar button... toggled through View > Show/Hide of course.
Support for userChrome.js 0.7 - userChrome.js tab, userChrome.xul tab. These tabs show only if those files are present.
Access to the chrome, profile and install folders. If interested, click the ChromEdit Plus in my sig... go to the bottom of the page.

Since SeaMonkey lacks an extension manager (built in) the userChrome.js extension seems well suited for it.
All that's needed now is a collection of .js and .xul targeted for SeaMonkey.
<a href="http://webdesigns.ms11.net/chromeditp.html" target="_blank">ChromEdit Plus</a> | <a href="http://webdesigns.ms11.net/winstripethemes.html" target="_blank">Firefox Themes</a>

Zoolcar9

User avatar
 
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)

Post Posted June 15th, 2006, 8:04 am


I only have one at http://www.extensionsmirror.nl/index.ph ... entry21446
deathburger could have more.

My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."

JNewbry

User avatar
 
Posts: 321
Joined: April 9th, 2005, 3:56 am
Location: Dallas,TX

Post Posted June 15th, 2006, 8:38 am

Zoolcar9... Thanks! That's a start.
My plans are to make up a zip file of SeaMonkey .js and .xul for everyone's use.
I'll post it when there's a decent collection.
<a href="http://webdesigns.ms11.net/chromeditp.html" target="_blank">ChromEdit Plus</a> | <a href="http://webdesigns.ms11.net/winstripethemes.html" target="_blank">Firefox Themes</a>

JNewbry

User avatar
 
Posts: 321
Joined: April 9th, 2005, 3:56 am
Location: Dallas,TX

Post Posted June 17th, 2006, 10:19 am

This is a userChrome.XUL file aimed at SeaMonkey users.

<a href="data:application/x-javascript;charset=utf-8;base64,PG92ZXJsYXkgaWQ9ImNsZWFyZGF0YSINCiAgICAgICAgIHhtbG5zPSJodHR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WFyIERhdGEiPg0KPG1lbnVwb3B1cD4NCjxtZW51aXRlbSBsYWJlbD0iQ2xlYXIgQ2FjaGUiIG9uY29tbWFuZD0iY2xlYXJBbGxDYWNoZSgpOyIgLz4NCjxtZW51c2VwYXJhdG9yIC8%2BDQo8bWVudWl0ZW0gbGFiZWw9IkNsZWFyIEhpc3RvcnkiIG9uY29tbWFuZD0iY2xlYXJIaXN0b3J5KCk7IiAvPg0KPG1lbnVzZXBhcmF0b3IgLz4NCjxtZW51aXRlbSBsYWJlbD0iQ2xlYXIgTG9jYXRpb24gQmFyIiBvbmNvbW1hbmQ9ImNsZWFyTG9jYXRpb25CYXIoKTsiIC8%2BDQo8bWVudXNlcGFyYXRvciAvPg0KPG1lbnVpdGVtIGxhYmVsPSJDbGVhciBDb29raWVzIiBvbmNvbW1hbmQ9ImNsZWFyQ29va2llcygpOyIgLz4NCjxtZW51c2VwYXJhdG9yIC8%2BDQo8bWVudWl0ZW0gbGFiZWw9IkNsZWFyIEFsbCIgb25jb21tYW5kPSJjbGVhckFsbERhdGEoKTsiIC8%2BDQo8L21lbnVwb3B1cD4NCjwvbWVudT4NCg0KICA8L3Rvb2xiYXJwYWxldHRlPg0KDQo8L292ZXJsYXk%2B">Clear Data</a>

This kinda mimics the "Clear Private Data" feature of Firefox.
Adds a "Clear Data" entry to the menubar.
Clears the Cache, History, Location Bar and Cookies. And a Clear All.
Yes... it was shamefully ripped from the prefbar extension.

*Update 6/23/2006 - I made this into an extension for SeaMonkey.
If interested... <a href="http://webdesigns.ms11.net/chromeditp.html#2">SeaMonkey Extensions</a>
Last edited by JNewbry on June 23rd, 2006, 10:58 am, edited 1 time in total.
<a href="http://webdesigns.ms11.net/chromeditp.html" target="_blank">ChromEdit Plus</a> | <a href="http://webdesigns.ms11.net/winstripethemes.html" target="_blank">Firefox Themes</a>

XerBlade

User avatar
 
Posts: 865
Joined: October 4th, 2005, 10:45 pm
Location: Nashville, TN, US

Post Posted June 18th, 2006, 4:23 pm

<a href="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QXR0cmlidXRlKCJhY2Nlc3NrZXkiLCAiRSIpOw%3D%3D">Make some labels like IE</a>

I made this as a concept script (please don't take what it's specifically doing seriously).
User Agent
Extensions
AMD64/2.41GHz RAM/1.0GB ATI/256MB-GDDR3/128-bit/8xAGP Cable6.0M/384kbps

SevenSeven
 
Posts: 33
Joined: February 8th, 2004, 1:05 pm

Post Posted June 22nd, 2006, 2:44 pm

zeniko,

Under a Guest account the JC shows "document.getElementById... has no properties" which disables my whole userChrome.js. It shows this error from another extension as well. Can it be fixed? I'm using 20060619 2.0a3.

old zeniko
 
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post Posted June 22nd, 2006, 2:59 pm

SevenSeven wrote:Under a Guest account the JC shows "document.getElementById... has no properties" which disables my whole userChrome.js.

Why, oh why? :roll: You explicitly left out the one relevant piece of information: the id of the element which is responsible for the error message. The error you're observing actually tries to tell you that that element couldn't be found (in that case getElementById returns <code>null</code> which doesn't have any properties). But of course we can't help you, unless you let us know what element that might be...

As for your having the whole userChrome.js disabled: consider using the Subscript Loader snippet from the first post and put each snippet into it's own file. Like this, you'll at most disable the code in the file you're currently working on.

SevenSeven
 
Posts: 33
Joined: February 8th, 2004, 1:05 pm

Post Posted June 22nd, 2006, 3:36 pm

zeniko wrote:
SevenSeven wrote:Under a Guest account the JC shows "document.getElementById... has no properties" which disables my whole userChrome.js.

Why, oh why? :roll: You explicitly left out the one relevant piece of information: the id of the element which is responsible for the error message. The error you're observing actually tries to tell you that that element couldn't be found (in that case getElementById returns <code>null</code> which doesn't have any properties). But of course we can't help you, unless you let us know what element that might be...

As for your having the whole userChrome.js disabled: consider using the Subscript Loader snippet from the first post and put each snippet into it's own file. Like this, you'll at most disable the code in the file you're currently working on.

Figured it out. ID is "sessionmanager-toolbar", which is missing in the Guest account config.

Zoolcar9

User avatar
 
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)

Post Posted June 22nd, 2006, 5:15 pm

zeniko wrote:As for your having the whole userChrome.js disabled: consider using the Subscript Loader snippet from the first post and put each snippet into it's own file. Like this, you'll at most disable the code in the file you're currently working on.

and add conditions as possible in every script.

My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."

SevenSeven
 
Posts: 33
Joined: February 8th, 2004, 1:05 pm

Post Posted June 23rd, 2006, 4:01 pm

Sharing some of my own 2.0a3-tested-only snippets:

- Auto clear searchbar after submit
- Auto show context menu upon selecting

<a href="data:application/x-javascript;charset=utf-8;base64,Lyo9PT09PT09IENsZWFyIHRoZSBzZWFyY2hiYXIgYWZ0ZXIgc3VibWl0ID09PT09PT0qLw0KDQp2YXIgc2VhcmNoYmFyQXV0b2NsZWFyID0gew0KCXNlYXJjaGJhclBvcHVwc2hvd2luZzogZmFsc2UsDQoJaW5pdDogZnVuY3Rpb24oKSB7ICANCgkJdGhpcy5zZWFyY2hiYXIgPSBkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgic2VhcmNoYmFyIik7DQoJCXZhciBzZWFyY2hiYXJUZXh0Ym94ID0gZG9jdW1lbnQuZ2V0QW5vbnltb3VzRWxlbWVudEJ5QXR0cmlidXRlKHRoaXMuc2VhcmNoYmFyLCAiYW5vbmlkIiwgInNlYXJjaGJhci10ZXh0Ym94Iik7DQoJCXNlYXJjaGJhclRleHRib3guYWRkRXZlbnRMaXN0ZW5lcigia2V5cHJlc3MiLCBmdW5jdGlvbihldmVudCkgeyBzZWFyY2hiYXJBdXRvY2xlYXIuY2xlYXIoZXZlbnQpOyB9LCBmYWxzZSk7DQoJCXZhciBnb0J1dHRvbiA9IGRvY3VtZW50LmdldEFub255bW91c0VsZW1lbnRCeUF0dHJpYnV0ZSh0aGlzLnNlYXJjaGJhciwgImFub25pZCIsICJzZWFyY2gtZ28tYnV0dG9uIik7DQoJCWdvQnV0dG9uLmFkZEV2ZW50TGlzdGVuZXIoImNsaWNrIiwgZnVuY3Rpb24oZXZlbnQpIHsgc2VhcmNoYmFyQXV0b2NsZWFyLmNsZWFyKGV2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ZXZlbnQua2V5Q29kZSA9PSAxMykgfHwgKGV2ZW50LmJ1dHRvbiA9PSAwKSkgew0KCQkJc2V0VGltZW91dCgic2VhcmNoYmFyQXV0b2NsZWFyLnNlYXJjaGJhci52YWx1ZT0nJzsiLCAwKTsNCgkJCXNldFRpbWVvdXQoInNlYXJjaGJhckF1dG9jbGVhci5zZWFyY2hiYXIuX3RleHRib3guX2Rpc3BsYXlDdXJyZW50RW5naW5lKCk7IiwgMCk7DQoJCQlldmVudC5zdG9wUHJvcGFnYXRpb24oKTsNCgkJfQ0KCX0NCn07DQpzZWFyY2hiYXJBdXRvY2xlYXIuaW5pdCgpOw%3D%3D">even better auto clear searchbar code - display current engine after submit</a>

<a href="data:application/x-javascript;charset=utf-8;base64,Lyo9PT09PT09IEF1dG8gY29udGV4dCBtZW51IG9uIHNlbGVjdGlvbiA9PT09PT09Ki8NCg0KdmFyIGF1dG9Db250ZXh0bWVudSA9IHsNCglleGVjOiBmdW5jdGlvbihldmVudCkgew0KCQlpZiAoZXZlbnQuYnV0dG9uICE9IDApIHJldHVybjsNCgkJdmFyIHNlbGVjdGlvbiA9IGRvY3VtZW50LmNvbW1hbmREaXNwYXRjaGVyLmZvY3VzZWRXaW5kb3cuZ2V0U2VsZWN0aW9uKCk7DQoJCWlmIChzZWxlY3Rpb24udG9TdHJpbmcoKSA9PSAiIikgcmV0dXJuOw0KCQlpZiAoZXZlbnQudHlwZSA9PSAibW91c2Vkb3duIikNCgkJCWlmICgoc2VsZWN0aW9uLnJhbmdlQ291bnQgPiAwKSAmJiAhc2VsZWN0aW9uLmdldFJhbmdlQXQoMCkuY29sbGFwc2VkKQ0KCQkJCWlmIChldmVudC50YXJnZXQudGFnTmFtZSAhPSAibWVudWl0ZW0iKQ0KCQkJCQlzZWxlY3Rpb24ucmVtb3ZlQWxsUmFuZ2VzKCk7DQoJCWlmICghc2VsZWN0aW9uLmlzQ29sbGFwc2VkKSB7DQoJCQl2YXIgbW91c2VFdmVudCA9IGRvY3VtZW50LmNyZWF0ZUV2ZW50KCJNb3VzZUV2ZW50cyIpOw0KCQkJbW91c2VFdmVudC5pbml0TW91c2VFdmVudCgiY29udGV4dG1lbnUiLCB0cnVlLCB0cnVlLCB3aW5kb3csIDEsIGV2ZW50LnNjcmVlblgsIGV2ZW50LnNjcmVlblksIGV2ZW50LmNsaWVudFgsIGV2ZW50LmNsaWVudFksIGZhbHNlLCBmYWxzZSwgZmFsc2UsIGZhbHNlLCAyLCBudWxsKTsNCgkJCWV2ZW50LnRhcmdldC5kaXNwYXRjaEV2ZW50KG1vdXNlRXZlbnQpOw0KCQl9DQoJfQ0KfTsNCmRvY3VtZW50LmFkZEV2ZW50TGlzdGVuZXIoIm1vdXNlZG93biIsIGZ1bmN0aW9uKGV2ZW50KSB7IGF1dG9Db250ZXh0bWVudS5leGVjKGV2ZW50KTsgfSwgZmFsc2UpOw0KZG9jdW1lbnQuYWRkRXZlbnRMaXN0ZW5lcigibW91c2V1cCIsIGZ1bmN0aW9uKGV2ZW50KSB7IGF1dG9Db250ZXh0bWVudS5leGVjKGV2ZW50KTsgfSwgZmFsc2UpOw0K">better auto context menu - now works for repeated selection of the same objects</a>
Last edited by SevenSeven on July 1st, 2006, 10:59 pm, edited 1 time in total.

imagr8m8
 
Posts: 117
Joined: August 6th, 2004, 3:39 pm

Post Posted June 27th, 2006, 6:18 pm

Can anyone help me write a script that will add "Open Contact" to the context menu of T-Bird when in the header of an email....needed to edit contact info, call a contact in response to an email or look at contact notes. It seems so intuitive to have this function instead of having to copy the address, open the addressbook, past the address into the search form and then select from a list to open a contact record....or hunt for the contact in ContactSidebar. Just right click the address and open the contact record.

The author of AddressContext has suggested for the last few months that he would eventually add it to his extension, but he's unable to work on it for a few more months....its hard to wait since we're constantly updating contact info all day long from emails received. I have UserChrome.js installed with some sample scripts working...and this seems like the perfect way to add this function.

Specifically, I'm looking to add "Open Contact" in the context menu above "Add to Address Book" when pointing at an email address in the preview pane or the summary in the thread pane. This menu item will find that email address in the address book and open that contact record for editing. If there are multiple matches, then display the list of matches as does the Address Book Search function. I see how to add the menu item and can even open the address book from it...but I need help with the code to actually search for and open the specific contact record.

Manually, I currently do this:
copy the address to the clipboard
Open the address book
paste the address into the search field
display list of matches
select the one that matches & open the contact record

Please...anyone.....can you scriptify it?

Old Ausdilecce
 
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post Posted June 29th, 2006, 4:00 pm

The first issue you will have is with the address.. In order to be assured that you are getting the correct contact, you will need to grab the email address ONLY ( not the name part, if there is one )

Then, it would be better to just open the 'edit contact' dialog directly, instead of going thru the addressbook window first..

In order to open the 'edit contact' dialog and have it work properly, you will need two pieces of info
1) the addressbook card of the contact in question
2) the addressbook directory URI that contains that contact

My addressbookpix extension can be helpful here. The extension does a search of all addressbooks for a contact that contains a particular email address. Storing the contact's card (if found) will give you item 1 and if that card is found, the directory it was found in will be available too..

Here is a snippit of code that will help you on your way (modified slightly from my addressBookPix extension..
feed the function a plaintext address and, if that address exists in *any* addressbooks, the edit card dialog will appear for it

Code: Select all
//********************************************************************************************************************************************
function editContact(address) {  // address is the plaintext address you get from currentHeaderData['from'].headerValue
    if (address == "") return;
    // the next couple lines will strip the name part from the address
    var separator = address.indexOf("<if> -1)  {
        var realAddress = address.substr(separator+1);
        realAddress = realAddress.substring(0,realAddress.indexOf(">"));
        address = realAddress;
    }
    var rdfService = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService(Components.interfaces.nsIRDFService);

    // enumerate all of the address books on this system
    var parentDir = rdfService.GetResource("moz-abdirectory://").QueryInterface(Components.interfaces.nsIAbDirectory);
    var enumerator = parentDir.childNodes;
    if (enumerator) {
        while (enumerator.hasMoreElements()) {
            var addrbook = enumerator.getNext();  // an addressbook directory
            addrbook.QueryInterface(Components.interfaces.nsIAbDirectory);
            var searchUri=addrbook.directoryProperties.URI + "?(or(PrimaryEmail,c," + address + "))";  // search for the address in this book
            var directory = rdfService.GetResource(searchUri).QueryInterface(Components.interfaces.nsIAbDirectory);
            // directory will now be a subset of the addressbook containing only those cards that match the searchstring 'address'
            try {
                var ChildCards = directory.childCards;
                ChildCards.first();
                var CurrentItem = ChildCards.currentItem();
            } catch(e) {
                var ChildCards = directory.childNodes;
                if (ChildCards.hasMoreElements()) var CurrentItem = ChildCards.getNext();               
            }
            // if the directory has *any* items, they will be matches of the address
            try {
                var CurrentCard = CurrentItem.QueryInterface(Components.interfaces.nsIAbCard);
                // current card is now the addressbook card of a contact that has 'address'
                if (CurrentCard.primaryEmail.toLowerCase() == address.toLowerCase()) {
                    // open the 'edit contact dialog for this card
                    var CurrentBookURI = addrbook.directoryProperties.URI;
                    window.openDialog(
                        "chrome://messenger/content/addressbook/abEditCardDialog.xul",
                        "",
                        "chrome,resizable=no,modal,titlebar,centerscreen",
                        {abURI:CurrentBookURI, card:CurrentCard, okCallback:null});
                    return;
                }
            }  catch (e)  {
                // we would be here if the directory contained no items
            }
            // if no match found above
            // lets now search the 'second email' of all the contacts in this addressBook
            var searchUri=addrbook.directoryProperties.URI + "?(or(SecondEmail,c," + address + "))";
            var directory = rdfService.GetResource(searchUri).QueryInterface(Components.interfaces.nsIAbDirectory);
            try {
                var ChildCards = directory.childCards;
                ChildCards.first();
                var CurrentItem = ChildCards.currentItem();
            } catch(e) {
                var ChildCards = directory.childNodes;
                if (ChildCards.hasMoreElements()) var CurrentItem = ChildCards.getNext();               
            }
            try {
                var CurrentCard = CurrentItem.QueryInterface(Components.interfaces.nsIAbCard);
                if (CurrentCard.secondEmail.toLowerCase() == address.toLowerCase()) {
                    // open the 'edit contact dialog for this card
                    var CurrentBookURI = addrbook.directoryProperties.URI;
                    window.openDialog(
                        "chrome://messenger/content/addressbook/abEditCardDialog.xul",
                        "",
                        "chrome,resizable=no,modal,titlebar,centerscreen",
                        {abURI:CurrentBookURI, card:CurrentCard, okCallback:null});
                    return;
                }
            }  catch (e)  {
                // we would be here if the directory contained no items
            }
        }
    }
}


Good luck

Old Greg S
 
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post Posted June 29th, 2006, 6:09 pm

When I use this code to add the find close button to the right within the ViewSource window, the code for sizing the customize toolbar window doesn't work. Any ideas?
Code: Select all
(function() {
  // WindowHook by zeniko
  var WindowHook = {
    observe: function(aSubject, aTopic, aData) {
      if(!aSubject._WindowHook) {
        aSubject._WindowHook = this;
        aSubject.addEventListener("load", this.onLoad_window, false);
      }
    },

    onLoad_window: function() {
      this.removeEventListener("load", this._WindowHook.onLoad_window, false);
      var funcs = this._WindowHook.mFuncs[this.document.location.href] || null;
      if(funcs) {
        funcs.forEach(function(aFunc) { aFunc(this); }, this);
      }
      delete this._WindowHook;
    },

    register: function(aURL, aFunc) {
      if(!this.mFuncs) {
        this.mFuncs = {};
        Components.classes["@mozilla.org/observer-service;1"]
          .getService(Components.interfaces.nsIObserverService)
          .addObserver(this, "domwindowopened", false);
      }
      if(!this.mFuncs[aURL]) {
        this.mFuncs[aURL] = [];
      }
      this.mFuncs[aURL].push(aFunc);
    }
  };

  //ViewSource
  WindowHook.register("chrome://global/content/viewSource.xul",
    function(aWindow) {
      // init findbar
      var findbar = aWindow.document.getElementById('FindToolbar');

      // move close button right
      findbar.appendChild(aWindow.document.createElement("toolbarspring"));
      findbar.appendChild(aWindow.document.getElementById("find-closebutton"));

    }
  );

})();

KidReefer

User avatar
 
Posts: 141
Joined: May 7th, 2006, 6:10 am
Location: Earth...mainly

Post Posted June 30th, 2006, 3:37 am

desertfox wrote:Presenting...
Mouse Gestures with userChrome.js
any suggestions for more gestures?

How about one to close current tab?
BTW...Great Work =D>
I love it so much I find myself trying to "gesture" outside of Firefox :lol:
Thanks again.

Zoolcar9

User avatar
 
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)

Post Posted July 1st, 2006, 12:36 am

Greg S wrote:When I use this code to add the find close button to the right within the ViewSource window, the code for sizing the customize toolbar window doesn't work. Any ideas?

All scripts that use WindowHook snippet must be in a same file.
  • <a href="data:application/x-javascript;base64,KGZ1bmN0aW9uKCkgewogIC8vc3RhcnQgV2luZG93SG9vayBzbmlwcGV0CiAgdmFyIFdpbmRvd0hvb2sgPSB7CiAgICBvYnNlcnZlOiBmdW5jdGlvbihhU3ViamVjdCwgYVRvcGljLCBhRGF0YSkgewogICAgICAvLy4uLi4uCiAgICB9LAogICAgb25Mb2FkX3dpbmRvdzogZnVuY3Rpb24oKSB7CiAgICAgIC8vLi4uLi4KICAgIH0sCiAgICByZWdpc3RlcjogZnVuY3Rpb24oYVVSTCwgYUZ1bmMpIHsKICAgICAgLy8uLi4uLgogICAgfQogIH07CiAgLy9lbmQgV2luZG93SG9vayBzbmlwcGV0CgogIC8vY3VzdG9taXplIHRvb2xiYXIgd2luZG93CiAgV2luZG93SG9vay5yZWdpc3RlcigiY2hyb21lOi8vZ2xvYmFsL2NvbnRlbnQvY3VzdG9taXplVG9vbGJhci54dWwiLAogICAgZnVuY3Rpb24oYVdpbmRvdykgewogICAgICAvLy4uLi4uCiAgICB9CiAgKTsKCiAgLy92aWV3IHNvdXJjZSB3aW5kb3cKICBXaW5kb3dIb29rLnJlZ2lzdGVyKCJjaHJvbWU6Ly9nbG9iYWwvY29udGVudC92aWV3U291cmNlLnh1bCIsCiAgICBmdW5jdGlvbihhV2luZG93KSB7CiAgICAgIC8vLi4uLi4KICAgIH0KICApOwoKICAvL290aGVyIHdpbmRvdwogIFdpbmRvd0hvb2sucmVnaXN0ZXIoImNocm9tZTovL2Zvby9jb250ZW50L2Zvby54dWwiLAogICAgZnVuY3Rpb24oYVdpbmRvdykgewogICAgICAvLy4uLi4uCiAgICB9CiAgKTsKCn0pKCk7IA%3D%3D">example</a>

My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 2 guests