Icon not updating - potential fix
![]() ![]() |
I noticed today that the icon stopped updating. After digging through the code, it seems that: self.searchElement is not being updated in the .poll function when new mail arrives or when reading a new mail (or maybe just its content is not being updated?), so the count is never updated to trigger redrawing the icon. I have no idea why this stopped working, or more to the point, how your previous code: if (!self.searchElement) was meant to work. It seems to me that test would only be valid once, and so wouldn't update beyond the first check anyway... but I digress. My fix was simple, remove the test and always update self.searchElement in the .poll function: this.poll = function() {
|
![]() ![]() |
I'm glad it's not just me! I want to try your fix, but... I can't figure out how to edit a script in FF4! Any ideas? |
![]() ![]() |
Addons -> User Scripts (left menu) -> right-click the script -> Edit |
![]() ![]() |
Right click! Duh! Thanks :) |
![]() ![]() |
At this point, I have been unable to break the script in any browser, including Firefox 4.0 RC. My guess is that the issue comes from an update to Gmail that modifies that the DOM and my accounts have yet to be updated with it. Based on both your testing and mine, I'm going to release your fix until I can narrow down why getSeachElement() is returning an element when it isn't the correct one. The purpose of if(!self.searchElement) {} is to account for when the script runs before the Inbox link is available in the DOM. If I were to refactor, I would only start polling after the link shows up in the DOM, but a refactor isn't in my cards for a few more months. Thanks for taking the time to figure this out and post. Your fix should be live in a few moments. |
![]() ![]() |
Oh yeah, I forgot to mention that I was using FF 4 RC. Best I can understand what's happening, is getSearchElement() is returning the correct element when GMail is initially loaded, and stores the element in self.searchElement. So if I refresh the page, the correct unread count/icon is displayed. However (and I don't know why this worked before) the element is not 'live'. In other words the data seems to be static from when it was returned from getSearchElement(). Since that function is only called once, the content never changes and the icon is not updated. I must refresh the page to update the count/icon. I noticed something odd in Chrome's 'Inspect Element' tool, unfortunately I don't have any historic data to compare to... but when inspecting the 'Inbox (n)' element that holds the unread count, after reading a message that element seems to disappear and is recreated. Visually in the tool, the element collapses and focus is placed on the parent node. Perhaps GMail is now replacing this element when the unread count changes (related to its own icon unread count functions?) and that breaks the stored element in self.searchElement. |
![]() ![]() |
The fix worked for me, thank you! |
![]() ![]() |
Ah, that could totally explain it. With the recreation of the element, we will have to query the DOM again. In a perfect world, the variable would just be unset when the node was removed from the DOM, but that might not be the case. I may be able to do some checking in getSearchElement() to see if the node is actually available so we don't have to query the DOM so frequently. Hopefully, I'll see the behavior myself soon! |
![]() ![]() |
This fix worked for me, too. Much appreciated! |
![]() ![]() |
Worked like a champ. Thanks! |
![]() ![]() |
Hmm... Still not working for me. I am using the latest nightly and Sriptish if that makes a difference. |
![]() ![]() |
icon action is perfect now, but now my audio sound for new email doesn't work (through better gmail 2). |
![]() ![]() |
@None Nosome: I'll have to try it with Scriptish, haven't done testing in it yet. I'll let you know what I find. @linkin06: I'm happy the icon works! The sound is actually handled by another userscript, and I'm not sure if they've updated it yet. You can report the issue there: http://userscripts.org/scripts/show/63100 |
![]() ![]() |
@None Nosome: I just tried it out in Scriptish and I doesn't look like the older version worked either, so it must be an incompatibility with Scriptish itself. I'll try to find some time this week to look into what's up. |
![]() ![]() |
Howdy all, I've downloaded the latest script to correct my non-updating favicon. The script I have doesn't seem to have the test "if (!self.searchElement)". Any other thoughts on how to get this to work again. Using FF4, Win7, Wooley. Thanks |
![]() ![]() |
The unread email count hasn't been working for a couple months for me. When I first signed it there would be the correct unread count, but it wouldn't be updated as I read my email. However, the chat notifications work just fine, so it wasn't a total 'break'. I'd tried the script update, and it didn't change a thing. Today, in looking through the labs, I noticed I had the "Title Tweaks" lab enabled. ("Changes order of elements in the browser title bar from "Gmail - Inbox (20) - [address]" to "Inbox (20) - [address] - Gmail". This way you are able (most of the time) to see if a new mail has arrived even if Gmail window is minimized.") On a hunch, I disabled the lab, and the script works perfectly now, just like it used to. It's possible that some people who are still having problems perhaps have this lab enabled... |


