That said, after doing some testing I think your issue is that the page isn't completely loaded before the addEventListener is called. Changing the addEventListener line to a simple element.onclick = function(alert) triggers an error in the browser; so does trying to ask about the element's onclick function. Putting in an alert box in place of the addEventListener line pretty clearly demonstrates that the page is still loading when the code is being called on the links. Firefox is a little touchy about that.
I'm still working on it, lemme see what happens if I wrap up your script's initialization section into a document.onload, or something similar.
Edit: Also, elements are being returned as XPCNativeWrapper objects [http://developer.mozilla.org/en/docs/XPCNativeWrapper]. I'm totally unfamiliar with those; maybe that's interfering with the event attachment somehow?
Edit: Yeah, looks like it. I wasn't sure, so I had to test, but references to elements from directly inside the code body get the XPCNativeWrapper objects, which provide protection for some properties. But, code called from a setTimeout doesn't get those objects, and gets direct access to the elements. Not sure how to fix that right since I've never encountered that before.
You can supposedly get access to the underlying JS object from the XPCNativeWrapper object with the wrappedJSObject property and then act on it, but it's a big security no-no. I tried it anyway to no avail.
Your thought on the page not being loaded is kind of where I ended up too. However, my understanding was that GM ran user scripts after the window.onload finished, but I could be completely wrong here. If I assign all the links id attributes in the GM script and then manually add event listeners in my Firebug console, they work fine. Also, you'll notice that later in my script I add click listeners on other items (buttons and links) that work swimmingly, so it's either entirely arbitrary or I'm missing something very obvious.
Thanks for looking at this, I'll look forward to any other thoughts you have.
EDIT: Looks like I was very wrong about the GM script executing after the window load event. I have been playing with wrapping code in a load event listener and have indeed got it working that way. Thanks for the suggestion! I'll hopefully have something polished and posted soon.
| You can supposedly get access to the underlying JS object from the XPCNativeWrapper object with the wrappedJSObject property and then act on it, but it's a big security no-no. I tried it anyway to no avail.
The other wrong way that I found out about was the unsafeWindow object; same kind of deal, gives you direct access to the page.
Firebug doesn't seem to be showing me any errors either.
BTW: I like the title of your blog, "Artfully Underemployed" :)
Since this is becoming more than just the simple blacklist script it originally was, I suppose I should rename it or something to make that more clear. ;)
Oh and I almost forgot, thanks for the brilliant idea!
Because it overrides the page itself you can't click "Back" or Alt+Left or whatever to go back to the list of stories. I did go back and add the check for if I'm already inside the frameset to my code though. Gotta prevent those recursive split views :). Now if you surf back to the main page in the right frame and click on a SplitView link it will reload both frames.
I will look at it in Safari some and see if I can figure out what the deal is there. Safari's Activity window doesn't show any errors.
I'll also see what I can think of for the Back button issue when doing it your way. That may not be a big deal to anyone else though.
Maybe it'll all be clear when I wake up.
New version is on the userscripts page for anyone that wants it: http://userscripts.org/scripts/show/25039
byId(thisnode.id).addEventListener('click', function(ev) { alert('test'); }, false);
Won't fire either.Went ahead and set it to what it should be... body.
Can someone please look at the code below (and read my comments in it) and tell me why the three addEventListeners that I have commented out won't work? I'd really really like to know why I am being retarded and how to fix it, as the solution I ended up with seems unnecessarily ugly.
View code here: http://userscripts.org/scripts/review/25039
Or if you don't care about it being ugly and just want to use it: http://userscripts.org/scripts/show/25039
But I'd really appreciate help with figuring out the issue with the addEventListeners.