<?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>Callum Macdonald &#187; remove onchange</title>
	<atom:link href="http://www.callum-macdonald.com/tag/remove-onchange/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.callum-macdonald.com</link>
	<description>Callum on life</description>
	<lastBuildDate>Mon, 06 Sep 2010 22:16:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>My first greasemonkey script</title>
		<link>http://www.callum-macdonald.com/2009/11/25/my-first-greasemonkey-script/</link>
		<comments>http://www.callum-macdonald.com/2009/11/25/my-first-greasemonkey-script/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 21:54:02 +0000</pubDate>
		<dc:creator>Callum</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Techy]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[onchange]]></category>
		<category><![CDATA[onclick]]></category>
		<category><![CDATA[remove onchange]]></category>
		<category><![CDATA[remove onclick]]></category>
		<category><![CDATA[unsafeWindow]]></category>
		<category><![CDATA[userscripts]]></category>
		<category><![CDATA[weather maps]]></category>
		<category><![CDATA[weather underground]]></category>
		<category><![CDATA[wrappedJSObject]]></category>
		<category><![CDATA[wunderground]]></category>

		<guid isPermaLink="false">http://www.callum-macdonald.com/?p=1800</guid>
		<description><![CDATA[On several ocassions I&#8217;ve looked for an animated weather map where I can see the predicted weather for a region. After some struggling, I found maps on weather underground that were close to what I wanted. However, when I changed &#8230; <a href="http://www.callum-macdonald.com/2009/11/25/my-first-greasemonkey-script/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>On several ocassions I&#8217;ve looked for an animated weather map where I can see the predicted weather for a region. After some struggling, I found <a title="Interactive, animated, live weather maps on Weather Underground" href="http://www.wunderground.com/ndfdimage/viewimage" target="_blank">maps on weather underground</a> that were close to what I wanted.</p>
<p>However, when I changed the date of the map, it loaded a whole new page with the new map for the new date. It was cumbersome to cycle through the dates. I figured I could write a little <a title="Install greasemonkey, it's awesome, and it's your web after all... :-)" href="https://addons.mozilla.org/firefox/addon/748" target="_blank">Greasemonkey</a> script to make life easier. Some 6 or so hours of hacking later, it&#8217;s done. It was much more finicky than I anticipated, but it&#8217;s done, and it works. I present <a title="My first greasemonkey script, Wunderground AJAXifier" href="http://www.callum-macdonald.com/code/wunderground-ajaxifier/" target="_self">Wunderground AJAXifier</a>.</p>
<h3>What is Greasemonkey?</h3>
<p>Greasemonkey is a plugin for Firefox that allows you to use custom scripts on various web sites. For example, I use the <a title="Take control of your YouTube experience with Greasemonkey and this script" href="http://userscripts.org/scripts/show/50771" target="_blank">YouTube without flash auto</a> script. When I load a YouTube video, the script removes the flash player and replaces it with an embed code that fires up my default browser plugin (VLC, xine, mplayer, etc). The script also creates a few links to download videos directly to my computer. Easy peasy.</p>
<p>There are thousands of scripts on <a title="UserScripts - a repository of user contributed greasemonkey scripts, awesomeness much" href="http://userscripts.org/" target="_blank">userscripts.org</a>. Mine is <a title="AJAXify Weather Underground, my first greasemonkey script" href="http://userscripts.org/scripts/show/62801" target="_blank">here</a>. Be warned, the first few scripts I installed were malicious, they redirected me to the author&#8217;s web site. I recommend you check the reviews and read the source code before installing any scripts.</p>
<h3>Philosophy</h3>
<p>I think greasemonkey is a really big development for browsers. It provides an easy way for users to customise and control their web experience. For example, it&#8217;s now relatively easy to reorganise your favourite web site to improve the layout, add a WSIWYG editor, and more. It&#8217;s a significant step for users to regain control of their web experience from site publishers. Power to the people! <img src='http://www.callum-macdonald.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h3>Removing onclick or onchange with Greasemonkey</h3>
<p>It took me quite a while to figure out how to remove the page&#8217;s default onchange event. I found the solution thanks to joeytwiddle on <a title="IRC link to the #greasemonkey channel on freenode" href="irc://irc.freenode.net/greasemonkey" target="_blank">#greasemonkey</a>. The trick is to use the wrappedJSObject method. Here&#8217;s a quick example:</p>
<p><code>var myel = document.getElementById('callum');<br />
console.log(myel.onchange); // null, see <a title="Greasemonkey quirkiness around the security model" href="http://wiki.greasespot.net/XPCNativeWrapper" target="_blank">XPCNativeWrapper</a><br />
console.log(myel.wrappedJSObject.onchange); // works<br />
myel.wrappedJSObject.onchange =  null; // unsets the onchange handler</code></p>
<p>It took me a while to figure this out, hopefully this post helps somebody else.</p>
<p>Here&#8217;s a completely unrelated image from a <a title="Flickr search for greasemonkey CC licensed photos" href="http://www.flickr.com/search/?q=greasemonkey&amp;z=t&amp;l=cc&amp;ss=2&amp;s=int" target="_blank">flickr search for greasemonkey</a> to brighten the post.</p>
<p><a href="http://www.flickr.com/photos/tonivc/2296010782/"><img class="aligncenter" title="Flickr Bug by ToniVC" src="http://farm4.static.flickr.com/3214/2296010782_8135a60574.jpg" alt="" width="500" height="375" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.callum-macdonald.com/2009/11/25/my-first-greasemonkey-script/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
