<?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>the empty quarter &#187; Web</title>
	<atom:link href="http://www.martinhammer.com/blog/index.php/category/techie/web/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.martinhammer.com/blog</link>
	<description>Sorry, but you are looking for something that isn’t here.</description>
	<lastBuildDate>Sat, 04 Feb 2012 12:33:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>Removing description from Firefox bookmarks</title>
		<link>http://www.martinhammer.com/blog/index.php/2011/04/removing-description-from-firefox-bookmarks/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2011/04/removing-description-from-firefox-bookmarks/#comments</comments>
		<pubDate>Mon, 18 Apr 2011 12:59:14 +0000</pubDate>
		<dc:creator>martin</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[sqlite]]></category>

		<guid isPermaLink="false">http://www.martinhammer.com/blog/?p=608</guid>
		<description><![CDATA[By default Firefox populates the Description field of a bookmark with the content of the page&#8217;s &#60;meta name="Description" content="..." /&#62; tag. I find is a little annoying and was looking for a way to remove these descriptions. Since I have a lot of bookmarks I wanted to clean them all up in one go rather [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-609 alignright" title="firefox_bookmark_description" src="http://www.martinhammer.com/blog/wp-content/uploads/2011/04/firefox_bookmark_description.png" alt="Description in a Firefox Bookmark" width="358" height="170" /></p>
<p style="text-align: left;">By default Firefox populates the Description field of a bookmark with the content of the page&#8217;s <code>&lt;meta name="Description" content="..." /&gt;</code> tag. I find is a little annoying and was looking for a way to remove these descriptions.</p>
<p style="text-align: left;">Since I have a lot of bookmarks I wanted to clean them all up in one go rather than editing them one by one. Luckily there is an easy way to do this since Firefox stores the bookmarks in an <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Sqlite">SQLite</a> database file which can be opened and manipulated.</p>
<ol style="text-align: left;">
<li>Install SQLite Database Browser (Ubuntu: <code>sudo apt-get install sqlitebrowser</code> Windows: <a href="http://sourceforge.net/projects/sqlitebrowser">download</a> and install from SourceForge).</li>
<li><strong>IMPORTANT!</strong> Export your Firefox bookmarks to have a backup in case something goes wrong.</li>
<li>Close Firefox (you can&#8217;t edit the bookmarks file while Firefox is running).</li>
<li>Run SQLite Database Browser and open the places.sqlite file which is located in your <a href="http://kb.mozillazine.org/Profile_folder">profile folder</a>.</li>
<li>Run the following SQL which will remove the description from <strong>all bookmarks</strong>.<br />
<code><br />
delete from moz_items_annos where anno_attribute_id = 2 </code>&nbsp;</p>
<p>&nbsp;</li>
<li>Save and close, run Firefox.</li>
</ol>
<p style="text-align: left;">Reference on the places.sqlite file can be found on <a href="http://kb.mozillazine.org/Places.sqlite">mozillaZine</a> and <a href="https://developer.mozilla.org/en/The_Places_database">Mozilla Developer Network</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2011/04/removing-description-from-firefox-bookmarks/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Managing Passwords with KeePass and KeePassX</title>
		<link>http://www.martinhammer.com/blog/index.php/2010/07/managing-passwords-with-keepass-and-keepassx/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2010/07/managing-passwords-with-keepass-and-keepassx/#comments</comments>
		<pubDate>Sat, 31 Jul 2010 04:07:33 +0000</pubDate>
		<dc:creator>martin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.martinhammer.com/blog/?p=508</guid>
		<description><![CDATA[Password proliferation is a serious problem on the web today. Most websites require users to register and create a username/password combination for future authentication. Unfortunately not many websites support reusable logins such as OpenID. The main problem is that of human memory. It is of course not reasonable to expect the user to remember 100+ [...]]]></description>
			<content:encoded><![CDATA[<p>Password proliferation is a serious problem on the web today. Most websites require users to register and create a username/password combination for future authentication. Unfortunately not many websites support reusable logins such as <a href="http://openid.net/">OpenID</a>.</p>
<p>The main problem is that of human memory. It is of course not reasonable to expect the user to remember 100+ unique passwords. In most cases, the end result is that users will reuse the same password for multiple sites and systems. The issues with this are obvious: if a malicious third party gets hold of one password, it compromises all where the password was used; also, by piecing together the other bits of data entered at registration (such as date of birth, gender, physical address, mother&#8217;s maiden name etc.) for different sites, the attacker might be able to create a very accurate profile which could then be used to gain access to even those systems where a different password was used.</p>
<p>That&#8217;s why I use a password management program, in particular <a href="http://keepass.info/">KeePass</a>/<a href="http://www.keepassx.org/">KeePassX</a>. It allows one to securely store credentials and is itself protected by strong encryption and can only be accessed using a password. In reality one finds that on a daily basis it is sufficient to remember 5-10 most frequently used passwords (computer login, email, Google, social network, internet banking and of course the password manager itself) and the rest can be referred to from KeePass. The program has a feature to generate random passwords, which is ideal to have strong passwords for infrequently accessed systems where one might not even realise the account was hacked for a long period of time. KeePass can even be installed in portable mode, which means you can carry the program and your encrypted passwords file on a USB stick.</p>
<p>I found that <a href="http://keepass.info/">KeePass</a> (version 1 for Windows) and <a href="http://www.keepassx.org/">KeePassX</a> (Linux and Mac) suit my needs perfectly. There is also a version for Android and iPhone (refer to the <a href="http://en.wikipedia.org/wiki/Keepass">Wikipedia article</a>). Best of all? It&#8217;s <a href="http://en.wikipedia.org/wiki/Free_software">free software</a> licensed under <a href="http://keepass.info/help/v1/license.html">GPL</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2010/07/managing-passwords-with-keepass-and-keepassx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disable cookies in Thunderbird</title>
		<link>http://www.martinhammer.com/blog/index.php/2010/05/disable-cookies-in-thunderbird/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2010/05/disable-cookies-in-thunderbird/#comments</comments>
		<pubDate>Sat, 15 May 2010 08:35:02 +0000</pubDate>
		<dc:creator>martin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[privacy]]></category>
		<category><![CDATA[thunderbird]]></category>

		<guid isPermaLink="false">http://www.martinhammer.com/blog/?p=490</guid>
		<description><![CDATA[Recently I discovered that by default Thunderbird accepts cookies from web content (version 3.0.4 in Ubuntu 10.04 Lucid). I am a bit baffled by what would be a valid use case for storing cookies in an email client, and so here are steps for disabling this option. Edit &#62; Preferences. Select Security icon and &#8220;Web [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">Recently I discovered that by default Thunderbird accepts cookies from web content (version 3.0.4 in Ubuntu 10.04 Lucid). I am a bit baffled by what would be a valid use case for storing cookies in an email client, and so here are steps for disabling this option.</p>
<ol>
<li>Edit &gt; Preferences.</li>
<li>Select Security icon and &#8220;Web Content&#8221; tab.</li>
<li>Untick &#8220;Accept cookies from sites&#8221;.</li>
<li>While you&#8217;re there, also check &#8220;Show Cookies&#8221; and &#8220;Remove All Cookies&#8221; to get rid of whatever has been stored up until now.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2010/05/disable-cookies-in-thunderbird/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Change Firefox address bar search engine</title>
		<link>http://www.martinhammer.com/blog/index.php/2010/01/change-firefox-address-bar-search-engine/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2010/01/change-firefox-address-bar-search-engine/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 14:10:36 +0000</pubDate>
		<dc:creator>martin</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://www.martinhammer.com/blog/?p=396</guid>
		<description><![CDATA[Follow these steps to change the search engine used by Firefox 3 address bar: Enter about:config in the browser&#8217;s address bar and accept a warning dialog if it appears. In the filter box type in keyword.URL Double click the entry and paste in your prefered search engine URL (e.g. http://www.bing.com/search?q=) You can always revert back [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">Follow these steps to change the search engine used by Firefox 3 address bar:</p>
<ol style="text-align: left;">
<li>Enter <code>about:config</code> in the browser&#8217;s address bar and accept a warning dialog if it appears.</li>
<li>In the filter box type in <code>keyword.URL</code></li>
<li>Double click the entry and paste in your prefered search engine URL (e.g. <code>http://www.bing.com/search?q=</code>)</li>
</ol>
<p style="text-align: left;">You can always revert back to the default Google search by right-clicking the entry and selecting the Reset menu option.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2010/01/change-firefox-address-bar-search-engine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Greasemonkey for beginners</title>
		<link>http://www.martinhammer.com/blog/index.php/2009/09/greasemonkey-for-beginners/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2009/09/greasemonkey-for-beginners/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 04:36:15 +0000</pubDate>
		<dc:creator>martin</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[greasemonkey]]></category>

		<guid isPermaLink="false">http://www.martinhammer.com/blog/?p=341</guid>
		<description><![CDATA[Tuxradar, a site worth keeping an eye on, published a basic Greasemonkey for beginners tutorial a little while back. Greasemonkey is a Firefox plugin which allows you to add little scripts which are executed when you browse to a particular page. The script can manipulate the page itself, e.g. to show additional content or to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.tuxradar.com">Tuxradar</a>, a site worth keeping an eye on, published a basic <a href="http://www.tuxradar.com/content/greasemonkey-beginners">Greasemonkey for beginners</a> tutorial a little while back. Greasemonkey is a Firefox plugin which allows you to add little scripts which are executed when you browse to a particular page. The script can manipulate the page itself, e.g. to show additional content or to hide annoying ads or whitespace, change style and much much more. Many thousands of scripts have been published and if you know Javascript and browser scripting it&#8217;s very easy to created your own. Here&#8217;s a couple of other Greasemonkey links:</p>
<ul>
<li><a href="http://www.tuxradar.com/content/greasemonkey-beginners">Greasemonkey for beginners</a> (Tuxradar)</li>
<li><a href="http://www.greasespot.net/">Greasespot</a></li>
<li><a href="http://diveintogreasemonkey.org/">Dive Into Greasemonkey</a> (the definite reference)</li>
<li><a href="http://userscripts.org/">userscripts.org</a> (a script repository)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2009/09/greasemonkey-for-beginners/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Apache Tomcat on Ubuntu server</title>
		<link>http://www.martinhammer.com/blog/index.php/2009/06/installing-apache-tomcat-on-ubuntu-server/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2009/06/installing-apache-tomcat-on-ubuntu-server/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 16:33:49 +0000</pubDate>
		<dc:creator>martin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://www.martinhammer.com/blog/?p=280</guid>
		<description><![CDATA[Here&#8217;s how to install Apache Tomcat version 5.5 on an Ubuntu machine (note that there is nothing Ubutu specific in these steps). This will form one of the foundation steps for a series of posts in which we will build a fully open-source business intelligence platform. First, install Java JDK. I am using Sun&#8217;s version [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">Here&#8217;s how to install <a href="http://tomcat.apache.org/">Apache Tomcat</a> version 5.5 on an Ubuntu machine (note that there is nothing Ubutu specific in these steps). This will form one of the foundation steps for a series of posts in which we will build a fully open-source business intelligence platform.</p>
<ol style="text-align: left;">
<li>First, install Java JDK. I am using Sun&#8217;s version mainly for stability and to avoid any compatibility issues.<br />
<code><br />
sudo apt-get install sun-java6-jdk</p>
<p></code></li>
<li>Download Apache Tomcat and check for integrity.<br />
<code><br />
wget http://mirrors.sirium.net/pub/apache/tomcat/tomcat-5/v5.5.27/bin/apache-tomcat-5.5.27.tar.gz<br />
wget http://mirrors.sirium.net/pub/apache/tomcat/tomcat-5/v5.5.27/bin/apache-tomcat-5.5.27.tar.gz.md5<br />
md5sum -c apache-tomcat-5.5.27.tar.gz.md5 </p>
<p></code>
</li>
<li>Unpack the archive file.<br />
<code><br />
tar xvzf apache-tomcat-5.5.27.tar.gz</p>
<p></code>
</li>
<li>Move the unpacked directory to its permanent location. I use /opt but this is only a personal preference.<br />
<code><br />
sudo mv apache-tomcat-5.5.27 /opt</p>
<p></code>
</li>
<li>Create a simple startup and shutdown script. Run <code>sudo vi /etc/init.d/tomcat</code> and save it with the following content:<br />
<code><br />
#!/bin/bash<br />
# Tomcat startup script</p>
<p>export JAVA_HOME=/usr/lib/jvm/java-6-sun</p>
<p>case $1 in<br />
start)<br />
	sh /opt/apache-tomcat-5.5.27/bin/startup.sh<br />
;;<br />
stop)<br />
	sh /opt/apache-tomcat-5.5.27/bin/shutdown.sh<br />
;;<br />
restart)<br />
	sh /opt/apache-tomcat-5.5.27/bin/shutdown.sh<br />
	sh /opt/apache-tomcat-5.5.27/bin/startup.sh<br />
;;<br />
*)<br />
	echo "Usage: /etc/init.d/tomcat {start|stop|restart}"<br />
	exit 1<br />
;;<br />
esac<br />
exit 0</p>
<p></code>
</li>
<li>Don&#8217;t forget to make this script executable.<br />
<code><br />
sudo chmod 755 /etc/init.d/tomcat</p>
<p></code>
</li>
<li>Now we can finally start Tomcat.<br />
<code><br />
/etc/init.d/tomcat start</p>
<p></code></li>
<li>Finally, check that everything worked correctly by opening the Tomcat default page (http://&lt;servername&gt;:8080) in a web browser.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2009/06/installing-apache-tomcat-on-ubuntu-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Goodbye WebMail, hello POP</title>
		<link>http://www.martinhammer.com/blog/index.php/2009/06/goodbye-webmail-hello-pop/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2009/06/goodbye-webmail-hello-pop/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 15:52:21 +0000</pubDate>
		<dc:creator>martin</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[hotmail]]></category>
		<category><![CDATA[thunderbird]]></category>

		<guid isPermaLink="false">http://www.martinhammer.com/blog/?p=267</guid>
		<description><![CDATA[For a long time the only way to access and use a Hotmail account from Thunderbird was the WebMail extension. All in all, this is a great solution but it always seemed a bit of a workaround since in the background it &#8220;pretends&#8221; to be a browser, downloads the Hotmail HTML and parses it to [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">For a long time the only way to access and use a <a href="http://www.hotmail.com">Hotmail</a> account from Thunderbird was the <a href="http://webmail.mozdev.org/">WebMail</a> extension. All in all, this is a great solution but it always seemed a bit of a workaround since in the background it &#8220;pretends&#8221; to be a browser, downloads the Hotmail HTML and parses it to get and send emails.</p>
<p style="text-align: left;">This has recently changed since the Hotmail team has come to its senses and now once again <a href="http://help.live.com/Help.aspx?market=en-US&amp;project=MailClassic&amp;querytype=topic&amp;query=WL_Mail_PROC_OEDAV.htm">allows POP3 and SMTP access</a> to the service. This means it is now straightforward to configure Thunderbird to use Hotmail, and no extensions are required.</p>
<p style="text-align: left;">As summarized by poster vtel57 on <a href="http://groups.google.com/group/thunderbird-webmail-extension/browse_thread/thread/abb1f38709ea8e09">Google Groups</a>:</p>
<blockquote><p>incoming server: pop3.live.com &#8211; port 995 &#8211; SSL<br />
outgoing server: smtp.live.com &#8211; port 587 &#8211; TLS<br />
Be sure that Secure Password Authentication is NOT checked.<br />
Works like a champ! :)</p></blockquote>
<p style="text-align: left;">Indeed it does, and we will even forgive vtel57 <a href="http://tafkac.org/afu/smileys/smileys_the_new_republic.html">the use of a smiley</a>.</p>
<p style="text-align: left;">One more thing to note is that once configured to use POP, Thunderbird will download the entire contents of your Hotmail inbox. So it is a good idea to do a bit of a clean up by deleting old items or moving them to an archive folder.</p>
<p style="text-align: left;">
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2009/06/goodbye-webmail-hello-pop/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Two quick changes in Firefox about:config</title>
		<link>http://www.martinhammer.com/blog/index.php/2009/04/two-quick-changes-in-firefox-aboutconfig/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2009/04/two-quick-changes-in-firefox-aboutconfig/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 12:41:54 +0000</pubDate>
		<dc:creator>martin</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[firefox]]></category>

		<guid isPermaLink="false">http://www.martinhammer.com/blog/?p=160</guid>
		<description><![CDATA[Here are two quick and simple changes which I always make on a fresh Firefox install. They are both accessed through the about:config URI. Simply type about:config to the Firefox address bar and accept the disclaimer. This reveals a lot of &#8220;hidden&#8221; settings which cannot be changed directly through the preferences dialogs. To make backspace [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">Here are two quick and simple changes which I always make on a fresh Firefox install. They are both accessed through the about:config URI. Simply type about:config to the Firefox address bar and accept the disclaimer. This reveals a lot of &#8220;hidden&#8221; settings which cannot be changed directly through the preferences dialogs.</p>
<ul style="text-align: left;">
<li>To make backspace button go back in history (this is default in Windows but not in Linux), change the value of <code>browser.backspace_action</code> to <code>0</code>.</li>
<li>To open the result of search from the search bar in a new tab change the value of <code>browser.search.openintab</code> to <code>true</code>.</li>
</ul>
<p style="text-align: left;">A reference of these and other about:config parameters can be found in the <a href="http://kb.mozillazine.org/Firefox_:_FAQs_:_About:config_Entries">MozillaZine Knowledge Base</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2009/04/two-quick-changes-in-firefox-aboutconfig/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Greasemonkey script to get book ISBN number using GM_xmlhttpRequest</title>
		<link>http://www.martinhammer.com/blog/index.php/2009/04/greasemonkey-script-to-get-book-isbn-number-using-gm_xmlhttprequest/</link>
		<comments>http://www.martinhammer.com/blog/index.php/2009/04/greasemonkey-script-to-get-book-isbn-number-using-gm_xmlhttprequest/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 19:21:52 +0000</pubDate>
		<dc:creator>martin</dc:creator>
				<category><![CDATA[Books]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.martinhammer.com/blog/?p=24</guid>
		<description><![CDATA[A bit of background: for a while now I have been buying books from the SF Masterworks series from Orion Publishing, mainly when I am in a bookshop and I see a book from the series which I don&#8217;t yet have. So far I have bought sixteen of the books, and I though it would [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">A bit of background: for a while now I have been buying books from the <a href="http://www.orionbooks.co.uk/Masterworks-SF-list.aspx">SF Masterworks</a> series from Orion Publishing, mainly when I am in a bookshop and I see a book from the series which I don&#8217;t yet have. So far I have bought sixteen of the books, and I though it would be nice to have the whole series (perhaps they will be considered collectable one day, who knows). Having spoken to my local bookshop, it turn out they would happy to order the rest of the series for me if I supply them with the books&#8217; ISBN numbers.</p>
<p style="text-align: left;">Now, the <a href="http://www.orionbooks.co.uk/Masterworks-SF-list.aspx">SF Masterworks</a> series page has a nice table with the books titles and authors as well as links to a more detailed page for each book. The table on the page can be nicely copied and pasted into a spreadsheet (<a href="http://docs.google.com">Google Docs</a> in my case) but the problem is that the ISBN numbers are not displayed on this over page, but on each book&#8217;s detailed page. Rather then having to click and copy &amp; paste 70 times, I thought this would be a good opportunity to play with the <a href="http://diveintogreasemonkey.org/api/gm_xmlhttprequest.html">GM_xmlhttpRequest</a> functionality in <a href="http://www.greasespot.net/">Greasemonkey</a>.</p>
<p style="text-align: left;">The script is <a href="http://userscripts.org/scripts/show/46923">uploaded</a> on <a href="http://userscripts.org/">userscripts.org</a> (together with a <a href="http://userscripts.org/users/41964/scripts">few of my other scripts</a>), although being targetted for a one-off job I don&#8217;t think it will become a hit!</p>
<p style="text-align: left;">So, what are the learnings from this little exercice?</p>
<p style="text-align: left;">At a high level, the logic being the script is something along the lines:</p>
<ol style="text-align: left;">
<li>Loop through the table</li>
<li>On each row get the link to the detailed page</li>
<li>Get the page via GM_xmlhttpRequest</li>
<li>Process the page to get the ISBN number</li>
<li>Display the ISBN number on the master page</li>
</ol>
<p style="text-align: left;">Naively, I fell into the trap of calling GM_xmlhttpRequest from a for loop. This doesn&#8217;t work because GM_xmlhttpRequest works in an asynchronous fashion, meaning that the rest of the code will not wait for it to finish.</p>
<p style="text-align: left;">I then read up quite a bit on the related topic of closures and scope in JavaScript and ultimately decided that whilst it&#8217;s a very interesting topic, for getting things done I needed an quicker and (for me ) an easier solution.</p>
<p style="text-align: left;">The way I decided to go was good old recursion (&#8220;you can&#8217;t understand recursion unless you understand recursion&#8221;). So an array of links to the detailed pages is built up first, then we iterate over them &#8211; but rather than having GM_xmlhttpRequest in the loop itself, I let its callback function increment the loop counter and call the next iteration. The counter and the array of links are global variables, to get around this tricky problem with closures.</p>
<p style="text-align: left;">As far as processing the results of GM_xmlhttpRequest, it is a bit of a letdown that they come as a text and it is not possible to use DOM (it can be done for XML with <a href="http://diveintogreasemonkey.org/patterns/parse-xml.html">DOMParser</a> but there is nothing in Greasemonkey for parsing HTML text). So to retrieve the value of the ISBN number from the detailed page it is back to plain old string search.</p>
<p style="text-align: left;">It&#8217;s probably not the cleanest solution out there, but given that the objective was to save some time and effort with manual copy &amp; paste for a one-off job, it works great. Following the <a href="http://en.wikipedia.org/wiki/KISS_principle">KISS principle</a>, I try not over-engineer something which is ultimately throwaway. At the same time, I got to play with GM_xmlhttpRequest for the first time, so the learning bonus is still there.</p>
<p style="text-align: left;">Now it&#8217;s off to the shop to get those books ordered &#8211; happy reading!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.martinhammer.com/blog/index.php/2009/04/greasemonkey-script-to-get-book-isbn-number-using-gm_xmlhttprequest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

