From: Matt Kruse on
On May 27, 2:17 pm, Garrett Smith <dhtmlkitc...(a)gmail.com> wrote:
> Check to see if #x exists prior to appending the container. If it does,
> the container not contain #x (unless the container has removed #x and
> appends it to itself at that time).

I am not appending the container. Facebook's code is. I am just trying
to trap the insertion of content and do something with it. That's why
I'm relying on the mutation events, because I can't hook into their
code and it's near impossible to comprehend even if I could.

> Mutation events have been known to hurt performance. I'm not up on the
> details of which mutation events hurt performance in which browsers.

I've not experienced any performance problems yet. It certain beats
repeatedly polling document.getElementById() to see if something was
inserted, which certainly has its own problems.

One frustration I do have is that DOMNodeInsertedIntoDocument does not
bubble like DOMNodeInserted does. Since I only watch to catch actual
insertions and not moving around of elements, I'd prefer the former
but I have to use the latter and process every insertion event.

> Generally I avoid mutation event because they don't work in IE <= 8.

I'd never used them before wandering into the wonderful world of
Greasemonkey where all I care about is Firefox/Chrome. It's a lovely
place. :)

Matt Kruse
From: Garrett Smith on
On 5/27/2010 12:38 PM, Matt Kruse wrote:
> On May 27, 2:17 pm, Garrett Smith<dhtmlkitc...(a)gmail.com> wrote:
>> Check to see if #x exists prior to appending the container. If it does,
>> the container not contain #x (unless the container has removed #x and
>> appends it to itself at that time).
>
> I am not appending the container. Facebook's code is. I am just trying
> to trap the insertion of content and do something with it. That's why
> I'm relying on the mutation events, because I can't hook into their
> code and it's near impossible to comprehend even if I could.
>

OK, so apparently there is there no way to know when FB appends the
container.

If #x will be only inserted at most once, then once it is inserted, the
callback that was listening for that, be it a facebook event, a mutation
event, or an event of your own design, can be removed.

>> Mutation events have been known to hurt performance. I'm not up on the
>> details of which mutation events hurt performance in which browsers.
>
> I've not experienced any performance problems yet. It certain beats
> repeatedly polling document.getElementById() to see if something was
> inserted, which certainly has its own problems.
>
> One frustration I do have is that DOMNodeInsertedIntoDocument does not
> bubble like DOMNodeInserted does. Since I only watch to catch actual
> insertions and not moving around of elements, I'd prefer the former
> but I have to use the latter and process every insertion event.
>

If the callback does not find #x, then it exits. Once #x is found, the
callback gets the information it needs and unregisters itself.

>> Generally I avoid mutation event because they don't work in IE<= 8.
>
> I'd never used them before wandering into the wonderful world of
> Greasemonkey where all I care about is Firefox/Chrome. It's a lovely
> place. :)
>

Greasemonkey? Does is actually work now? I remember all sorts of
problems with it. For some reason guys at Yahoo love it. I remember guys
going out of there way to keep old versions of Firefox just to avoid the
problems with it not working in the upgrade.
From: Matt Kruse on
On May 27, 10:56 pm, Garrett Smith <dhtmlkitc...(a)gmail.com> wrote:
> OK, so apparently there is there no way to know when FB appends the
> container.

True.

> If #x will be only inserted at most once, then once it is inserted, the
> callback that was listening for that, be it a facebook event, a mutation
> event, or an event of your own design, can be removed.

Unfortunately, they do some strange ajax navigation stuff. Containers
get added, then removed, seemingly at random. My goal is to trap the
cases where the containers exist, and insert my content. If they get
removed and added again as the user navigates, add the stuff again. So
I keep my listeners around.

> Greasemonkey? Does is actually work now? I remember all sorts of
> problems with it. For some reason guys at Yahoo love it. I remember guys
> going out of there way to keep old versions of Firefox just to avoid the
> problems with it not working in the upgrade.

It works great for me. Not sure of what issues exist. FWIW,
http://BetterFacebook.net is the code I'm tinkering with. It's evolved
into kind of a sloppy mess right now, but I'm re-writing portions of
it to better use these mutation events in an attempt to make it more
robust.

Matt Kruse