Download script: mod_remove_dupes_from_google.user.js.
Summary
A script, Remove Dupes from Google Reader to remove the display of duplicates in Google Reader was not working and missing desired features. Other scripts didn’t work out. Further details on the situation are available at the posted Ask MetaFilter question.
Resolution
Fixed, enhanced.
New features
The script was corrected to work with Google Reader. It was enhanced so that duplicates were not simply unbolded for a session, a status which was lost on refresh and not reflected in the new items count. Duplicates are now checked by link, as well as the original title plus summary. Duplicates can be marked as read with an automatic refresh to remove them from the new items view by clicking the “Remove Dupes+Refresh” button. The button itself can be right-clicked with the mouse (ctrl-click on single button mouse, context menu click for others) to change to “Remove Dupes Only” and back again. When clicking “Remove Dupes Only”, there is no refresh and duplicates marked as read remain, but are not bolded (the normal message read display).
Remarks
• All messages to be checked for duplicates must be loaded in the viewer. If they are not loaded, they will not be checked.
• The original script was heavily modified. Only a couple of functions from it remain relatively intact.
• To fix the script’s basic operation, a lookup based on bad class name was changed to a valid class name. Miscellaneous bits of noncritical code which bugged me were changed, though not a lot.
• The default “Remove Dupes+Refresh” button performs a duplicate check, then simulates a button press of “Refresh” to force the display to update. If the button is changed to “Remove Dupes Only” by right-clicking on it, the refresh does not occur.
• The enhancement to mark messages as read with Reader stats updates is actually not completely understood by me, and I wrote it. Originally, I thought it could only be done through the poorly and not-officially documented Google Reader API, but this would be a terribly messy process, especially since not all the necessary information could be found.
Instead, I thought to simulate a click on a link for each duplicate to test other ways to make the script work. The links have to be clicked for Google Reader to internally process the message as read in its private data storage. The test approach, I thought, would quickly load each link in the Reader and then the page would go away for subsequent links. This would be suboptimal, but I hoped to later mitigate the page loading to get an acceptable message read process.
Happily, it didn’t happen that way. Instead, the duplicate links were quickly processed and marked as read by the simulated link click, with no external page loading. I’m not sure whether this is because they were processed so quickly, or due to some form of arcana in the parameters passed to the initMouseEvent() function.
March 10, 2009 at 10:43 pm |
Got a mail on this, so I’ll copy in a follow-up comment on changing the look of the new button…
The new button is ugly compared to the Google buttons because it’s a bog-standard default button, while the Google buttons are really nested divs which are built and massaged to their final form through classes and styles.
You can easily insert a new style for the button; simply give it a unique class name and use the GM_addStyle() function. After the existing script line:
dupeNode.setAttribute(“id”, rdID);
add the two lines:
dupeNode.setAttribute(“class”, “SomeGoofyClass”);
GM_addStyle(“button.SomeGoofyClass { height: 20px }”);
where SomeGoofyClass is replaced by the name of your new class name (or keep that one), and the style changes the button height to 20 px. Modify and add to the style to your heart’s content.