<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Thin &#38; Light &#187; Greasemonkey</title>
	<atom:link href="http://thinlight.org/tag/greasemonkey/feed/" rel="self" type="application/rss+xml" />
	<link>http://thinlight.org</link>
	<description>Passion for the web</description>
	<lastBuildDate>Sun, 30 May 2010 06:04:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>DOMContentLoaded and Greasemonkey</title>
		<link>http://thinlight.org/2008/11/29/domcontentloaded-and-greasemonkey/</link>
		<comments>http://thinlight.org/2008/11/29/domcontentloaded-and-greasemonkey/#comments</comments>
		<pubDate>Sat, 29 Nov 2008 13:47:55 +0000</pubDate>
		<dc:creator>thinlight</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Greasemonkey]]></category>
		<category><![CDATA[onload]]></category>

		<guid isPermaLink="false">http://thinlight.org/?p=83</guid>
		<description><![CDATA[A very common purpose of Greasemonkey scripts is modifying the DOM structure of the document, mostly adding something new.
I&#8217;ve written several scripts before and have been doing such modifications in the &#8220;load&#8221; event handler, as in this script. The problem is that &#8220;load&#8221; event is fired after all images on the page have been downloaded [...]]]></description>
			<content:encoded><![CDATA[<p>A very common purpose of Greasemonkey scripts is modifying the DOM structure of the document, mostly adding something new.</p>
<p>I&#8217;ve written several scripts before and have been doing such modifications in the &#8220;load&#8221; event handler, as in <a href="http://userscripts.org/scripts/review/30613">this script</a>. The problem is that &#8220;load&#8221; event is fired after all images on the page have been downloaded completely, so users may suffer a great delay to see the changes occur if there&#8217;re many images.</p>
<p><a href="http://jquery.com/">jQuery</a> users know that jQuery has a function &#8220;ready&#8221;. It won&#8217;t wait for the images to load. We are writing Greasemonkey scripts, so we only care about Firefox. Firefox has a &#8220;DOMContentLoaded&#8221; event explained in detail <a href="https://developer.mozilla.org/en/Gecko-Specific_DOM_Events">here</a>.</p>
<blockquote><p>Fired on a Window object when a document&#8217;s DOM content is finished loaded, but unlike &#8220;load&#8221;, does not wait till all images are loaded. Used for example by GreaseMonkey to sneak in to alter pages before they are displayed.</p></blockquote>
<p>So when writing my last script I tried to rely on this event:</p>
<pre><code>window.addEventListener('DOMContentLoaded', function(e) {
	...
}, false);
</code></pre>
<p>But the codes in the handler were not executed.</p>
<p>I was confused and did some searching. Finally I got <a href="http://wiki.greasespot.net/DOMContentLoaded">this page</a> saying that &#8220;the code in a Greasemonkey user script gets invoked when the DOMContentLoaded event fires&#8221;. That explains all. The &#8220;DOMContentLoaded&#8221; event was already fired so the codes never had a chance to get executed.</p>
<p>The solution, of course, is pulling the handler codes out of the wrapper. If your script doesn&#8217;t really rely on the &#8220;load&#8221; event, don&#8217;t put them into its handler because there may be a obvious delay.</p>
]]></content:encoded>
			<wfw:commentRss>http://thinlight.org/2008/11/29/domcontentloaded-and-greasemonkey/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Google Reader Unread Count</title>
		<link>http://thinlight.org/2008/07/27/google-reader-unread-count/</link>
		<comments>http://thinlight.org/2008/07/27/google-reader-unread-count/#comments</comments>
		<pubDate>Sun, 27 Jul 2008 07:58:31 +0000</pubDate>
		<dc:creator>thinlight</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Gmail]]></category>
		<category><![CDATA[Google Reader]]></category>
		<category><![CDATA[Greasemonkey]]></category>

		<guid isPermaLink="false">http://thinlight.org/?p=77</guid>
		<description><![CDATA[Gmail is my Firefox home page and is always open as long as Firefox is there. So I wrote this Greasemonkey script to show Google Reader&#8217;s unread count in the nav-bar of Gmail. A good place, isn&#8217;t it?

The script checks for the unread count every 8 minutes. But after you click the &#8220;Reader&#8221; link, it [...]]]></description>
			<content:encoded><![CDATA[<p>Gmail is my Firefox home page and is always open as long as Firefox is there. So I wrote this Greasemonkey script to show Google Reader&#8217;s unread count in the nav-bar of Gmail. A good place, isn&#8217;t it?</p>
<p><a href="http://userscripts.org/scripts/show/30613"><img width="424" height="94" class="alignnone" title="Unread count" src="http://thinlight.org/wp-content/uploads/2008/07/gmail-reader.png" alt=""/></a></p>
<p>The script checks for the unread count every 8 minutes. But after you click the &#8220;Reader&#8221; link, it checks the count 1 minute later and extend the interval by 1 minute after every check until the interval returns to 8 minutes again.</p>
<p>Install <a href="https://addons.mozilla.org/en-US/firefox/addon/748">Greasemonkey</a>，and then <a href="http://userscripts.org/scripts/source/30613.user.js">install this script</a>。</p>
<p><a href="http://userscripts.org/scripts/show/30613">Page on userscripts.org</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://thinlight.org/2008/07/27/google-reader-unread-count/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Toggling the Google Reader Shared Items Panel</title>
		<link>http://thinlight.org/2008/02/01/toggling-the-google-reader-shared-items-panel/</link>
		<comments>http://thinlight.org/2008/02/01/toggling-the-google-reader-shared-items-panel/#comments</comments>
		<pubDate>Fri, 01 Feb 2008 16:38:07 +0000</pubDate>
		<dc:creator>thinlight</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Google Reader]]></category>
		<category><![CDATA[Greasemonkey]]></category>
		<category><![CDATA[userscript]]></category>

		<guid isPermaLink="false">http://thinlight.org/2008/02/01/toggling-the-google-reader-shared-items-panel/</guid>
		<description><![CDATA[I&#8217;m a fan of Google Reader. Although FeedDemon went free recently and it offers synchronization with NewsGator which is great attraction for many people, I still couldn&#8217;t drop Google Reader.
However the panel above the subscription list takes up too much space for my humble screen resolution of 1024&#215;768. As Google rolled out the much complained [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a fan of Google Reader. Although <a href="http://www.newsgator.com/Individuals/FeedDemon/">FeedDemon</a> went free recently and it offers synchronization with <a href="http://www.newsgator.com/">NewsGator</a> which is great attraction for many people, I still couldn&#8217;t drop Google Reader.</p>
<p>However the panel above the subscription list takes up too much space for my humble screen resolution of 1024&#215;768. As Google <a href="http://googlereader.blogspot.com/2007/12/reader-and-talk-are-friends.html">rolled out</a> the much complained &#8220;Friends&#8217; shared items&#8221; feature, it became an urgent task for me to hide the annoying but never used panel. It took up 1/3 of the vertical space on the left sidebar!</p>
<p>No, not just hiding. Sometimes I need to clear the number of unread friends&#8217; shared items. So it should be a &#8220;toggler&#8221; like the sidebar (or nav-bar as called by Google) toggler natively built in Google Reader. Like this:</p>
<p>Before hiding, with mouse hovering on the toggler:</p>
<p><img src='http://thinlight.org/wp-content/uploads/2008/02/hide-share.png' alt='toggler' /></p>
<p>When the panel is hidden:</p>
<p><img src='http://thinlight.org/wp-content/uploads/2008/02/share-hidden.png' alt='panel hidden' /></p>
<p>You can still open it at any time. Basically, it works in the same way as the native sidebar toggler.</p>
<p>This is done by writing a user script for <a href="https://addons.mozilla.org/en-US/firefox/addon/748">Greasemonkey</a>, so you must have Greasemonkey installed to use it.</p>
<p><a href="http://thinlight.org/toolbox/firefox/userscripts/google-reader-share-panel-toggler.html">Get it now</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://thinlight.org/2008/02/01/toggling-the-google-reader-shared-items-panel/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
