<?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>MacLovin &#187; Scripts</title>
	<atom:link href="http://www.maclovin.de/category/scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.maclovin.de</link>
	<description>An Apple a day keeps the Windows away</description>
	<lastBuildDate>Thu, 25 Feb 2010 20:57:44 +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>Access OS X keychain from Terminal</title>
		<link>http://www.maclovin.de/2010/02/access-os-x-keychain-from-terminal/</link>
		<comments>http://www.maclovin.de/2010/02/access-os-x-keychain-from-terminal/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 20:57:44 +0000</pubDate>
		<dc:creator>Dennis</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.maclovin.de/?p=526</guid>
		<description><![CDATA[At everyday scripting, you often need to access sensible information like passwords. A common practice is to just write them plain text into your script, but at least on a Mac, we can do better.
OS X ships with a tool called keychain. It is a central database where tools can store sensitive information like logins. [...]]]></description>
			<content:encoded><![CDATA[<p>At everyday scripting, you often need to access sensible information like passwords. A common practice is to just write them plain text into your script, but at least on a Mac, we can do better.</p>
<p>OS X ships with a tool called keychain. It is a central database where tools can store sensitive information like logins. Luckily, it is accessible from shell scripts with the command line utility <strong>security</strong>.</p>
<p>Let&#8217;s say you want to securely access an FTP server&#8217;s username and password. First of all, add a new Internet password to your keychain. To do so, just fire it up, select <em>New password</em> and enter the credentials. Remember to add the prefix http:// or ftp:// to your service name to create an Internet password.</p>
<div id="_mcePaste"><a href="http://www.maclovin.de/wp-content/uploads/2010/02/keychain-internet-password.png" title="Keychain Internet Password" rel="lightbox[526]"><img class="aligncenter size-full wp-image-532" title="Keychain Internet Password" src="http://www.maclovin.de/wp-content/uploads/2010/02/keychain-internet-password.png" alt="" width="425" height="394" /></a></div>
<p>Now you read the username like this from the command line</p>
<div id="_mcePaste">
<pre class="brush: bash;light: true">security find-internet-password -s ftp.home.com | grep "acct" | cut -d '"' -f 4</pre>
</div>
<p>The service is what you entered in keychain, but without the prefix. And finally your password</p>
<div id="_mcePaste">
<pre class="brush: bash;light: true">security 2&gt;&amp;1 &gt;/dev/null find-internet-password -gs ftp.home.com | cut -d '"' -f 2</pre>
</div>
<div id="_mcePaste">That&#8217;s all. No more plain text passwords in your script.</div>
]]></content:encoded>
			<wfw:commentRss>http://www.maclovin.de/2010/02/access-os-x-keychain-from-terminal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Robust HTML parsing the Groovy way</title>
		<link>http://www.maclovin.de/2010/02/robust-html-parsing-the-groovy-way/</link>
		<comments>http://www.maclovin.de/2010/02/robust-html-parsing-the-groovy-way/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 19:50:06 +0000</pubDate>
		<dc:creator>Dennis</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.maclovin.de/?p=445</guid>
		<description><![CDATA[With Groovy, it&#8217;s very easy to parse XML data and extract arbitrary information. This works great as long as the input data is well-formed, but you can&#8217;t always guarantee that in real-world scenarios. Think of extracting data from HTML pages. They are very often a mess when it comes to XML validity and that&#8217;s where [...]]]></description>
			<content:encoded><![CDATA[<p>With Groovy, it&#8217;s very easy to parse XML data and extract arbitrary information. This works great as long as the input data is well-formed, but you can&#8217;t always guarantee that in real-world scenarios. Think of extracting data from HTML pages. They are very often a mess when it comes to XML validity and that&#8217;s where the <a title="TagSoup" href="http://home.ccil.org/~cowan/XML/tagsoup/" target="_blank">TagSoup library</a> comes to the rescue.</p>
<p><span id="more-445"></span></p>
<p>There are two major problems with HTML input:</p>
<ul>
<li>DTD resolution</li>
<li>Missing closing tags</li>
</ul>
<p>We are going to build a simple Groovy script that prints the list of questions on StackOverflow&#8217;s start page. The straight forward solution looks something like that</p>
<pre class="brush: groovy">def slurper = new XmlSlurper()
def htmlParser = slurper.parse("http://stackoverflow.com/")

htmlParser.'**'.findAll{ it.@class == 'question-hyperlink'}.each {
	println	it
}</pre>
<p>We parse <a href="http://stackoverflow.com" target="_blank">http://stackoverflow.com</a> with XMLSlurper, loop over all tags with the class attribute &#8216;question-hyperlink&#8217; and print it. But when running the script we get the following exception:</p>
<blockquote>
<div id="_mcePaste">Caught: java.io.IOException: Server returned HTTP response code: 503 for URL: http://www.w3.org/TR/html4/strict.dtd at html_parser.run(html_parser.groovy:7)</div>
</blockquote>
<div>XMLSlurper has problems with HTML DTDs. By using the information in <a title="Groovy XmlSlurper and HTTP 503 Response Code" href="http://stevefinck.blogspot.com/2009/12/groovy-xmlslurper.html" target="_blank">this post</a>, we get rid of the exception.</div>
<div>
<pre class="brush: groovy;highlight: 2">def slurper = new XmlSlurper()
slurper.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false)
def htmlParser = slurper.parse("http://stackoverflow.com/")

htmlParser.'**'.findAll{ it.@class == 'question-hyperlink'}.each {
	println	it
}</pre>
</div>
<div>So next try. The DTD exception is gone, but we get another one saying the closing link-tag is missing. And here comes TagSoup. It&#8217;s a library that tries to transform invalid HTML data into well-formed XML. And best of all, it works great together with XMLSlurper. Here is the final Script:</div>
<div>
<pre class="brush: groovy">@Grab(group='org.ccil.cowan.tagsoup',
      module='tagsoup', version='1.2' )
def tagsoupParser = new org.ccil.cowan.tagsoup.Parser()
def slurper = new XmlSlurper(tagsoupParser)
def htmlParser = slurper.parse("http://stackoverflow.com/")

htmlParser.'**'.findAll{ it.@class == 'question-hyperlink'}.each {
	println	it
}</pre>
</div>
<div>The first command uses the @Grab-annotation to load the TagSoup library. Next we create a TagSoup-Parser instance and pass it as constructor-parameter to XMLSlurper. That&#8217;s all and we even got rid of the <em>setFeature</em> workaround.</div>
<div>You know other tricks to make HTML parsing more robust? Then please leave them in the comments.</div>
]]></content:encoded>
			<wfw:commentRss>http://www.maclovin.de/2010/02/robust-html-parsing-the-groovy-way/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Launchbar: Dialing phone numbers with Fritz!Box Part 2</title>
		<link>http://www.maclovin.de/2010/02/launchbar-dialing-phone-numbers-with-fritzbox-part-2/</link>
		<comments>http://www.maclovin.de/2010/02/launchbar-dialing-phone-numbers-with-fritzbox-part-2/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 21:25:46 +0000</pubDate>
		<dc:creator>Dennis</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[launchbar]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.maclovin.de/?p=458</guid>
		<description><![CDATA[This is a follow-up article of Launchbar: Dialing phone numbers with Fritz!Box, where I explained how to use Launchbar for dialing phone numbers via FritzBox.
Meanwhile, AVM has changed the login procedure and the original script no longer works. With the help of this example, it&#8217;s finally doing its job again.
Special thanks go to Christopher Füseschi [...]]]></description>
			<content:encoded><![CDATA[<p>This is a follow-up article of <a href="http://www.maclovin.de/2009/05/launchbox-dialing-phone-numbers-with-fritzbox-applescript/" target="_self">Launchbar: Dialing phone numbers with Fritz!Box</a>, where I explained how to use Launchbar for dialing phone numbers via FritzBox.</p>
<p>Meanwhile, AVM has changed the login procedure and the original script no longer works. With the help of <a href="http://wehavemorefun.de/fritzbox/Hilfsprogramme_/_Tipps_&amp;_Tricks#Anrufliste_von_der_Box_holen_.28Beispiel_f.C3.BCr_neues_Loginverfahren_mit_SID.29" target="_blank">this example</a>, it&#8217;s finally doing its job again.</p>
<p>Special thanks go to Christopher Füseschi (ICQ 40520202) for pointing me to this issue and also for doing final tests.</p>
<p>You can download the updated script <a href="http://www.maclovin.de/wp-content/uploads/2010/02/dial-with-fritzbox.scpt">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maclovin.de/2010/02/launchbar-dialing-phone-numbers-with-fritzbox-part-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Launchbar: Dialing phone numbers with Fritz!Box (Applescript)</title>
		<link>http://www.maclovin.de/2009/05/launchbox-dialing-phone-numbers-with-fritzbox-applescript/</link>
		<comments>http://www.maclovin.de/2009/05/launchbox-dialing-phone-numbers-with-fritzbox-applescript/#comments</comments>
		<pubDate>Sun, 17 May 2009 19:20:55 +0000</pubDate>
		<dc:creator>Dennis</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[launchbar]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.maclovin.de/?p=245</guid>
		<description><![CDATA[Update: The script on this page no longer works. Please refer to this one.
Launchbar is a very convenient application launcher for Mac OS X. Among other great features like instant send, it can execute a script when invoking a phone number from your address book. I own a Fritz!Box 7170, which is one of the [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update: The script on this page no longer works. Please refer to </strong><a href="http://www.maclovin.de/2010/02/launchbar-dialing-phone-numbers-with-fritzbox-part-2/"><strong>this one</strong></a><strong>.</strong></p>
<p><a title="Launchbox" href="http://www.obdev.at/products/launchbar/" target="_blank">Launchbar</a> is a very convenient application launcher for Mac OS X. Among other great features like instant send, it can execute a script when invoking a phone number from your address book. I own a Fritz!Box 7170, which is one of the most famous combination of WLAN router and telephone system in Germany. By sending special HTTP POST-requests to the Fritz!Box, you can dial phone numbers from your computer. I wrote a <a href="http://www.maclovin.de/wp-content/uploads/2009/05/dial-with-fritzbox.scpt">small Applescript</a> which glues both features together.<span id="more-245"></span></p>
<p>The installation is pretty simple. First of all, open the script in Apple&#8217;s script editor and adjust the parameters. The password and the phone port are very likely to change. Save it to <em>Library/Application Support/Launchbar/Actions</em> under your Home folder. The script assumes that you are using Launchbar 5, which currently is in public Beta. Now open Launchbares preferences, choose <em>Actions</em> and select the script for phone numbers.</p>
<p><a href="http://www.maclovin.de/wp-content/uploads/2009/05/dial-with-fritzbox-setup.png" title="Dial with Fritzbox (Setup)" rel="lightbox[245]"><img class="aligncenter size-full wp-image-250" title="Dial with Fritzbox (Setup)" src="http://www.maclovin.de/wp-content/uploads/2009/05/dial-with-fritzbox-setup.png" alt="Dial with Fritzbox (Setup)" width="430" height="312" /></a></p>
<p>That&#8217;s all. Now fire up Launchbar, navigate to an entry from your address book, select a number and hit enter. The script immediately tries to call the number and prints a message in large print on the screen. After the specified delay (25 seconds by default), the script gives up reaching the number.</p>
<p><a href="http://www.maclovin.de/wp-content/uploads/2009/05/dialing-fritzbox.png" title="Dialing with Frit!Box" rel="lightbox[245]"><img class="aligncenter size-full wp-image-249" title="Dialing with Frit!Box" src="http://www.maclovin.de/wp-content/uploads/2009/05/dialing-fritzbox.png" alt="Dialing with Frit!Box" width="502" height="60" /></a></p>
<p>The script is based on a shell script by Christian Felder posted <a href="http://www.cybton.com/view_thread,FritzBox+_+lwp_request,26152,1.html" target="_blank">here</a> and an expample script for dialing with Skype from Launchbar found in its help.</p>
<p>You can download the script here <a href="http://www.maclovin.de/wp-content/uploads/2009/05/dial-with-fritzbox.scpt">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maclovin.de/2009/05/launchbox-dialing-phone-numbers-with-fritzbox-applescript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create RSS feeds with PHP</title>
		<link>http://www.maclovin.de/2009/03/create-rss-feeds-with-php/</link>
		<comments>http://www.maclovin.de/2009/03/create-rss-feeds-with-php/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 21:24:05 +0000</pubDate>
		<dc:creator>Dennis</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.maclovin.de/?p=138</guid>
		<description><![CDATA[RSS is a format for publishing frequently changing content like news, a list of blog posts or directories. Using RSS readers like Google Reader or Apple Mail, you can read all your daily information at one place, offering a much better overview and faster processing than visiting every single website.
An RSS feed from the technical [...]]]></description>
			<content:encoded><![CDATA[<p>RSS is a format for publishing frequently changing content like news, a list of blog posts or directories. Using RSS readers like Google Reader or Apple Mail, you can read all your daily information at one place, offering a much better overview and faster processing than visiting every single website.</p>
<p>An RSS feed from the technical point of view is nothing more than a specially formatted XML document. It contains a general feed description as well as a headline, a link to the source and the content or an excerpt for every item. In this arcticle, I will show you how to create your own feed using PHP.</p>
<p><span id="more-138"></span></p>
<p>First of all, we set up the <strong>header information</strong> to specify that it is an XML document.</p>
<pre class="brush: php">&lt;?
header("Content-Type: text/xml; charset=utf-8");
print "&lt;?xml version=\"1.0\" ?&gt;\n";
?&gt;</pre>
<p>Then we add <strong>general feed information</strong> like the feed&#8217;s name, its description and the source URL.</p>
<pre class="brush: xml;first-line: 5">&lt;rss version="2.0"&gt;
&lt;channel&gt;

&lt;title&gt;Feed's title&lt;/title&gt;
&lt;description&gt;My site's cool feed&lt;/description&gt;
&lt;link&gt;http://www.my-site.com&lt;/link&gt;</pre>
<p>Now the real work begins. We need to get the necessary information for every item to be published. This could mean simply selecting information from a database, but also parsing XML or HTML files and gathering the information we need. It all depends on the datasource. When looping over every single item of our information, I assume we fill the variables <em>$item</em>, <em>$content</em> and <em>$link</em>, containing what the name suggests. We print the following block for every step of the loop.</p>
<pre class="brush: php;first-line: 35">&lt;item&gt;
  &lt;title&gt;&lt;?= $title ?&gt;&lt;/title&gt;
  &lt;description&gt;&lt;?= $content ?&gt;&lt;/description&gt;
  &lt;link&gt;&lt;?= $link ?&gt;&lt;/link&gt;
&lt;/item&gt;</pre>
<p>Finally, we close the opened tags.</p>
<pre class="brush: xml;first-line: 46">&lt;/channel&gt;
&lt;/rss&gt;</pre>
<p>That&#8217;s pretty much all you need to set up your own feed. But there are some pitfalls I discovered when creating my first feed. Because we&#8217;re working with XML documents, we have to convert special characters like &lt; and &gt; to &amp;lt; and &amp;gt;. This can be archieved by using PHP&#8217;s  <strong>htmlspecialchars</strong> funtion. However, I had to use it <em>twice</em> for a proper display in Google Reader. I would have expected Google to escape the content properly, but looks like they just pass the output to the frontend.</p>
<p>Now I wish you a lot of fun creating your own feed. If you need some information on how to parse HTML files with PHP and create  an RSS feed from almost any website, just leave a comment and I will provide some examples.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maclovin.de/2009/03/create-rss-feeds-with-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Twitter URLs using Quicksilver</title>
		<link>http://www.maclovin.de/2009/01/twitter-urls-using-quicksilver/</link>
		<comments>http://www.maclovin.de/2009/01/twitter-urls-using-quicksilver/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 22:43:04 +0000</pubDate>
		<dc:creator>Dennis</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[quicksilver]]></category>
		<category><![CDATA[safari]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.maclovin.de/?p=66</guid>
		<description><![CDATA[Wouldn&#8217;t it be nice to send the URL you&#8217;re currently looking at in Safari directly to Twitter by just executing a Quicksilver command or even by hitting a hotkey? I think, yes it is! And so I wrote an Applescript that performs the folowing tasks:

Read the URL and title of the website currently shown in [...]]]></description>
			<content:encoded><![CDATA[<p>Wouldn&#8217;t it be nice to send the URL you&#8217;re currently looking at in Safari directly to Twitter by just executing a Quicksilver command or even by hitting a hotkey? I think, yes it is! And so I wrote an Applescript that performs the folowing tasks:</p>
<ol>
<li>Read the URL and title of the website currently shown in Safari</li>
<li>Create a short URL using <a href="http://is.gd/" target="_blank">is.gd</a></li>
<li>Open <a href="http://twitter.com/" target="_blank">Twitter</a> in Safari showing a message like &#8220;The site&#8217;s title (http://is.gd/abcd)&#8221;</li>
<li>Additionally the short URL is copied to the clipboard</li>
</ol>
<p><a href="http://www.maclovin.de/wp-content/uploads/2009/01/quicksilver-twitter-url.png" title="Twitter URL with Quicksilver" rel="lightbox[66]"><img class="aligncenter size-medium wp-image-71" title="Twitter URL with Quicksilver" src="http://www.maclovin.de/wp-content/uploads/2009/01/quicksilver-twitter-url-300x181.png" alt="Twitter URL with Quicksilver" width="300" height="181" /></a></p>
<p>Just copy the script to a directory where Quicksilver can find it and you&#8217;re done. Tweeting an interesing website is a breeze. You could even set up a Quicksilver trigger and assign a hotkey for even easier execution.</p>
<p><a href="http://www.maclovin.de/wp-content/uploads/2009/01/twitter-message.png" title="Twitter message" rel="lightbox[66]"><img class="aligncenter size-medium wp-image-72" title="Twitter message" src="http://www.maclovin.de/wp-content/uploads/2009/01/twitter-message-299x91.png" alt="Twitter message" width="299" height="91" /></a></p>
<p>The script itself uses some snippets from external resources. <a href="http://www.leancrew.com/all-this/2007/11/long-and-shortened-url-scripts/">This site</a> is a great overview on how to shorten URLs with Applescript and how to use it with Quicksilver. A routine for finding and replacing text can be found <a href="http://foolsworkshop.com/applescript/2008/05/an-applescript-replace-text-method/">here</a>.</p>
<p>Download the script: <a href="http://www.maclovin.de/wp-content/uploads/2009/01/twitter-url.scpt">Twitter URL</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.maclovin.de/2009/01/twitter-urls-using-quicksilver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Applescript: add document currently shown in Safari to Delicious</title>
		<link>http://www.maclovin.de/2009/01/applescript-add-document-currently-shown-in-safari-to-delicious/</link>
		<comments>http://www.maclovin.de/2009/01/applescript-add-document-currently-shown-in-safari-to-delicious/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 21:21:42 +0000</pubDate>
		<dc:creator>Dennis</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[quicksilver]]></category>
		<category><![CDATA[safari]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.maclovin.de/?p=42</guid>
		<description><![CDATA[ 
I just switched from Firefox to Safari and was looking for a nice way to add the website currently shown in Safari to my Delicious bookmarks. Delicious itself offers a bookmarklet for that purpose, but I prefer leaving the bookmark bar hidden. So I came up with a litte Applescript&#8230;
 
 
It does nothing more than telling Safari [...]]]></description>
			<content:encoded><![CDATA[<p> <br />
I just switched from Firefox to Safari and was looking for a nice way to add the website currently shown in Safari to <a href="http://delicious.com/frommi">my Delicious bookmarks</a>. Delicious itself offers a bookmarklet for that purpose, but I prefer leaving the bookmark bar hidden. So I came up with a litte <a href="http://www.maclovin.de/wp-content/uploads/2009/01/delicious_add_from_safari.scpt">Applescript</a>&#8230;</p>
<p> </p>
<div id="attachment_51" class="wp-caption aligncenter" style="width: 283px"><a href="http://www.maclovin.de/wp-content/uploads/2009/01/save-a-bookmark-on-delicious.png" title="Save a Bookmark on Delicious" rel="lightbox[42]"><img class="size-medium wp-image-51" title="Save a Bookmark on Delicious" src="http://www.maclovin.de/wp-content/uploads/2009/01/save-a-bookmark-on-delicious-273x299.png" alt="Save a Bookmark on Delicious" width="273" height="299" /></a><p class="wp-caption-text">Dialog shown after execution of script</p></div>
<p> </p>
<p>It does nothing more than telling Safari to execute the same Javascript as the bookmarklet would do. Calling it from within an Applescript has one huge advantage called Quicksilver. I set up a trigger to execute this script with the scope of Safari (scopes seem to be broken in Leopard) and assigned the hotkey CMD-D.</p>
<p>This trigger in combination with Quicksilver&#8217;s &#8220;Social bookmarks&#8221; plugin is a great way use delicious with Safari.</p>
<p>Download the script: <a href="http://www.maclovin.de/wp-content/uploads/2009/01/delicious_add_from_safari.scpt">delicious_add_from_safari</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.maclovin.de/2009/01/applescript-add-document-currently-shown-in-safari-to-delicious/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add book price comparison to Amazon</title>
		<link>http://www.maclovin.de/2008/08/add-book-price-comparison-to-amazon/</link>
		<comments>http://www.maclovin.de/2008/08/add-book-price-comparison-to-amazon/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 21:27:02 +0000</pubDate>
		<dc:creator>Dennis</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.maclovin.de/?p=17</guid>
		<description><![CDATA[I wrote a small Greasemonkey-Script, that adds links to the most famous German book price comparisons to the Amazon website.

Greasemonkey is a Firefox-Addon providing the possibility to customize web-pages using Javascript and DOM. The script I wrote is based on the Amazon Linky script and performs the following tasks on every page at amazon (tested [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote a small Greasemonkey-Script, that adds links to the most famous German book price comparisons to the Amazon website.</p>
<p style="text-align: center;"><a href="http://www.maclovin.de/wp-content/uploads/2008/08/buchpreis.png" rel="lightbox" title="Amazon bookprice comparison" rel="lightbox[17]"><img class="size-medium wp-image-27 aligncenter" title="Amazon bookprice comparison" src="http://www.maclovin.de/wp-content/uploads/2008/08/buchpreis-300x182.png" alt="" width="300" height="182" /></a></p>
<p><a title="Greasemonkey" href="http://www.greasespot.net/"><span id="more-17"></span>Greasemonkey</a> is a Firefox-Addon providing the possibility to customize web-pages using Javascript and DOM. The script I wrote is based on the <a title="Amazon Linky" href="http://userscripts.org/scripts/show/1058">Amazon Linky script</a> and performs the following tasks on every page at amazon (tested on amazon.de, but should work with other TLDs as well):</p>
<ol>
<li>Parse the page and try to find the ISBN number</li>
<li>Abort processing if none was found. That&#8217;s the case if you are not looking at product details but e.g. search results or the product shown is not a book.</li>
<li>Search for the tag at the position where links should be added (under the &#8220;used &amp; new&#8221; link)</li>
<li>Create the links to the search engines</li>
<li>Insert the new tags into the page</li>
</ol>
<p>Most of the steps should be quite self-explanatory when looking at the script&#8217;s source code. The most difficult part is setting up the URLs to the search engines. I got them by visiting the book price comparison and performing a search for the ISBN number of an arbitrary book. Then on the result page, I had a closer look at the address bar. If you&#8217;re lucky then the ISBN number entered appears somewhere in the URL. Just try to search for another book by exchanging the ISBN in the URL with another one. If that works (and it does most of the time), you&#8217;re ready to go.</p>
<p>Edit the script&#8217;s source and use one of the already existing engines as template. Paste your URL as href-attribute in it and adjust it to read the ISBN number from the variable &#8220;isbn&#8221;.</p>
<p><a href="http://www.maclovin.de/wp-content/uploads/2008/08/amazon_buchpreis.user.js">amazon_buchpreis.user.js</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.maclovin.de/2008/08/add-book-price-comparison-to-amazon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
