<?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>Dereferenced.com &#187; JavaScript</title>
	<atom:link href="http://www.dereferenced.com/topics/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dereferenced.com</link>
	<description>A preponderance of Perl, an excess of XML, and additional alliterations.</description>
	<lastBuildDate>Tue, 17 Jan 2012 17:18:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>GreaseMonkey: Hide the ToC on search.cpan.org Module Pages</title>
		<link>http://www.dereferenced.com/2009/07/31/greasemonkey-hide-the-toc-on-search-cpan-org-module-pages/</link>
		<comments>http://www.dereferenced.com/2009/07/31/greasemonkey-hide-the-toc-on-search-cpan-org-module-pages/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 07:29:39 +0000</pubDate>
		<dc:creator>rjray</dc:creator>
				<category><![CDATA[CPAN]]></category>
		<category><![CDATA[GitHub]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Perl]]></category>

		<guid isPermaLink="false">http://www.dereferenced.com/?p=26</guid>
		<description><![CDATA[I love it when tools do exactly what they&#8217;re supposed to, do it effectively, and in doing so let me do things quickly and easily. Like any serious Perl programmer, I use search.cpan.org several times a day. Indeed, I even have it as a search plug-in for Firefox. But when I am looking at the [...]]]></description>
			<content:encoded><![CDATA[<p>I love it when tools do exactly what they&#8217;re supposed to, do it effectively, and in doing so let me do things quickly and easily.</p>
<p>Like any serious Perl programmer, I use <a href="http://search.cpan.org">search.cpan.org</a> several times a day. Indeed, I even have it as a <a href="http://groups.google.com/group/comp.lang.perl.misc/browse_thread/thread/2e5ad1cb25569ea9/44318577d969b032?lnk=gst">search plug-in for Firefox</a>. But when I am looking at the manual pages for modules, I find the auto-generated table of contents to be cumbersome. I always just scroll past it to get at the meat. Yes, I could click on the links to jump to sections, but then browser-back has to be clicked that many more times to get back to the main distribution page, search results page, etc.</p>
<p>So I did the obvious thing: I set out to write a <a href="http://www.greasespot.net/">GreaseMonkey</a> script to scratch this particular itch. And in this case, JavaScript was just easy-enough to use, and GM just helpful-enough, that before I knew it the task was done. I had initially planned to just put together the basic framework, make sure it was locating the needed <tt>&lt;div&gt;</tt> tags, etc. But that worked right the first time, so I thought I&#8217;d go ahead and have it hide the ToC. That took even less time, so I went ahead and put in a clickable <tt>&lt;span&gt;</tt> tag to toggle the hidden/exposed state of the ToC. And before I realized it, I&#8217;d pretty much finished the whole task.</p>
<p>There were two &#8220;gotchas,&#8221; of sorts, that I had to spend a little time fixing:</p>
<ul>
<li>Seems that you can&#8217;t set the style for CSS pseudo-selectors, &#8220;<tt>:hover</tt>&#8221; in this case, via JavaScript. So I solved this by creating an additional element, a &lt;script&gt; tag, to provide hover-styling for the clickable text.</li>
<li>The <tt>&lt;span&gt;</tt> tag displayed as a block object, and as such the &#8220;hot&#8221; area actually extended well to the right of the text. I solved <em>this</em> part by just wrapping the span in another <tt>&lt;div&gt;</tt>. Then the span was treated as inline, and the &#8220;hot&#8221; part is limited to the bounding-box of the text only.</li>
</ul>
<p>So, the script is being tracked on <a href="http://github.com">GitHub</a>, the project page is <a href="http://github.com/rjray/gm-hide-cpan-toc/tree/master">here</a>. Also, I uploaded it to <a href="http://userscripts.org">userscripts.org</a>, and you can install it from it&#8217;s <a href="http://userscripts.org/scripts/show/54773">page there</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dereferenced.com/2009/07/31/greasemonkey-hide-the-toc-on-search-cpan-org-module-pages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

