<?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"
	>

<channel>
	<title>ArunRocks &#187; greasemonkey</title>
	<atom:link href="http://www.arunrocks.com/blog/archives/category/greasemonkey/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.arunrocks.com/blog</link>
	<description>Representing Anti-Monotonistic Tendencies</description>
	<pubDate>Sat, 22 Nov 2008 05:49:53 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Forget Pages with Autopagerize</title>
		<link>http://www.arunrocks.com/blog/archives/2008/11/17/forget-pages-with-autopagerize/</link>
		<comments>http://www.arunrocks.com/blog/archives/2008/11/17/forget-pages-with-autopagerize/#comments</comments>
		<pubDate>Sun, 16 Nov 2008 18:49:57 +0000</pubDate>
		<dc:creator>Arun bhai</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[Technical]]></category>

		<category><![CDATA[firefox]]></category>

		<category><![CDATA[greasemonkey]]></category>

		<category><![CDATA[productivity]]></category>

		<guid isPermaLink="false">http://www.arunrocks.com/blog/?p=136</guid>
		<description><![CDATA[     <link rel="alternate" type="application/atom+xml" title="ArunRocks Category: General" href="http://www.arunrocks.com/blog/archives/category/general/feed/" />
     <link rel="alternate" type="application/atom+xml" title="ArunRocks Category: Technical" href="http://www.arunrocks.com/blog/archives/category/technical/feed/" />
     <link rel="alternate" type="application/atom+xml" title="ArunRocks Category: firefox" href="http://www.arunrocks.com/blog/archives/category/firefox/feed/" />
     <link rel="alternate" type="application/atom+xml" title="ArunRocks Category: greasemonkey" href="http://www.arunrocks.com/blog/archives/category/greasemonkey/feed/" />
     <link rel="alternate" type="application/atom+xml" title="ArunRocks Category: productivity" href="http://www.arunrocks.com/blog/archives/category/productivity/feed/" />
Reddit had a heated debate about the AJAX paging pattern. The debate sidetracked into the benefits of Paging. Nobody seemed to mention the excellent greasemonkey script Autopagerize which is proof that the concept works brilliantly. I find it one of the most indispensable Greasemonkey scripts available today.
The idea is simple. Assume you are reading a [...]]]></description>
			<content:encoded><![CDATA[<p>Reddit had a heated debate about the <a href="http://looksgoodworkswell.blogspot.com/2005/06/death-to-paging-rico-livegrid-released.html">AJAX paging pattern</a>. The debate sidetracked into the benefits of Paging. Nobody seemed to mention the excellent greasemonkey script <a href="http://userscripts.org/scripts/show/8551">Autopagerize</a> which is proof that the concept works brilliantly. I find it one of the most indispensable Greasemonkey scripts available today.</p>
<p>The idea is simple. Assume you are reading a blog in blogspot.com. When you scroll towards the end of the blog, Autopagerize realizes that you are really interested in reading more blog posts. In other words, soon you would click on &#8216;Older Entries&#8217; links. This would have caused a fresh page to load. How terribly annoying! Instead, Autopagerize will silently load the older posts in the background and seamlessly add them to the end of the page. By the time you finish reading the second page, the third page will be added to the end and so on and so forth. This results in a smooth and breezy browsing experience, which has to be experienced to be believed.</p>
<h3>Installing Autopagerize</h3>
<p><a href="http://userscripts.org/scripts/show/8551">Autopagerize</a> uses greasemonkey plugin and hence works only if you have Firefox installed. The steps are quite simple:</p>
<ol>
<li>Install <a href="https://addons.mozilla.org/en-US/firefox/addon/748">Greasemonkey</a></li>
<li>Go to <a href="http://userscripts.org/scripts/show/8551">Autopagerize script</a> page and click on &#8216;Install this Script&#8217; button</li>
<li>Visit any of the supported sites e.g. <a href="http://stackoverflow.com/questions/tagged/python">stackoverflow.com</a> or a blog like <a href="http://userscripts.org/scripts/show/8551">simblog</a></li>
<li>If the page supports Autopagerize, a green square will appear at the top right of the page. Scroll to the end and it will momentarily turn blue to indicate that the next page is loading in the background.</li>
</ol>
<p><img src="/blog/wp-content/photos/autopager/00-autopagerize.png" alt="Autopagerize in action" /></p>
<h3>How does Autopagerize work?</h3>
<p>Autopagerize works on all kinds of sites which have pages. But how does it manage to understand the structure of them all? The answer is the community maintained SITEINFO database which is the result of hundreds of hours of effort.</p>
<p>Autopagerize is turned on for a particular site if its URL matches the <strong>url</strong> property. Once the page is loaded, it searches for the next link based on the xpath provided by <strong>nextLink</strong> property. The next page&#8217;s content is identified by the <strong>pageElement</strong> property. Anything which is not part of this content is discarded. This content is then appended to the existing page either by appending as a sibling to the existing <strong>pageElement</strong> or if <strong>insertBefore</strong> is defined, it is inserted before the element identified by  <strong>insertBefore</strong> property. </p>
<h3>How to Add any Website to Autopagerize?</h3>
<p><em>Note: This is not for the faint of heart. It involves opening and working with some code (to the extend of editing some regular expressions).</em></p>
<p>So you would like extend the Autopagerize experience to more and more sites? Don&#8217;t worry, you have come to the right place. For this section you would need to install the excellent Firebug plugin. Firebug&#8217;s javascript console is the best interactive XPath debugger I am aware of.</p>
<p><span id="more-136"></span></p>
<p>First, ensure that Firebug console is activated for your site. Visit the page you would like to Autopagerize say <a href="http://www.adobetutorialz.com/articles/2751/1/Professional-Web-Layout-for-Business-Solutions">http://www.adobetutorialz.com/articles/2751/1/Professional-Web-Layout-for-Business-Solutions</a>. Click on the firebug icon and enable the Console by checking the first check box (as shown in the figure). Click on Enable. Now the page gets refreshed and the Console appears.</p>
<p><img src="/blog/wp-content/photos/autopager/01-firebug-console.png" alt="Firebug Console" /></p>
<p>Next, go to the Firefox menu item: Tools -> Greasemonkey -> Manage User Scripts. Select Autopagerize from the list and click on Edit button below. </p>
<p><img src="/blog/wp-content/photos/autopager/02-greasemonkey-dialog.png" alt="Greasemonkey Option" /></p>
<p>Turn on debugging by changing line 26 (could be different for you) to <code>var DEBUG = 1</code>. However I could make debugging work only after adding the following 3 lines further down, say after line 85.</p>
<pre><code>if(unsafeWindow.console){
   var GM_log = unsafeWindow.console.log;
}
</code></pre>
<p>Scroll to the line that starts with <code>var SITEINFO = [</code>, which is around line 40. Copy and uncomment the 6 lines of sample code provided by the author as shown in the figure.</p>
<p><img src="/blog/wp-content/photos/autopager/03-emacs-screen.png" alt="Editing code in Emacs" /></p>
<p>Now, give the appropriate XPATH values to the property variables &#8220;pageElement&#8221; and &#8220;nextLink&#8221;. The &#8220;url&#8221; variable is a simple regular expression and an example link for the fourth variable (this variable is purely for documentation). Save this file and refresh your page. If the XPATH values are correctly found the Autopagerize green square icon will appear on the page, else there will be some error on your Firebug console like:</p>
<pre><code>nextLink not found
</code></pre>
<h3>Debugging Autopagerize or Shit, Nothing Happens!</h3>
<p>As you might have guessed, the last step I mentioned earlier is not so easy. This is where Firebug can help you. Before you start read some <a href="http://www.w3schools.com/Xpath/">XPATH tutorials</a> on the net to familiarize yourself with the XPATH syntax. </p>
<p>One killer feature in Firebug is selecting any element of a page and copying the XPath value of that element. On the Firebug window click on Firebug&#8217;s Inspect button and mousing over the page to outline that page element (see fig). </p>
<p><img src="/blog/wp-content/photos/autopager/04-inspect.png" alt="Firebug Inspect" /></p>
<p>Click on the page element you are interested in and the details of the element appear on the firebug window. Right clicking on any item in the breadcrumb at the very top, you will see a Copy XPath option (see fig). </p>
<p><img src="/blog/wp-content/photos/autopager/05-copy-xpath.png" alt="Copying XPATH" /></p>
<p>Now go to the console tab of Firebug and test the XPath by using the $x function. Paste the XPath as an argument to this function and you should get an HTMLElement as the result (see fig).</p>
<p><img src="/blog/wp-content/photos/autopager/06-firebug.png" alt="Paste to Console" /></p>
<p>You will need to find variables: &#8220;pageElement&#8221; and &#8220;nextLink&#8221; this way. This is not an exact science and involves a lot of trial and error. Here are some tips I found after several hours of testing:</p>
<ol>
<li><strong>Escaping</strong> - You will need to add a backslash &#8216;\&#8217; before each special character like &#8216;/&#8217; or &#8220;. This is not required in the Firebug console, however.</li>
<li><strong>Single Quotes</strong> - It is best to use single-quotes as the outer-most quotes in the Firebug console</li>
<li><strong>Firebug gives Absolute Paths</strong> - You will find that Firebug gives XPaths based on the position of a child element, which is likely to break even if the smallest change is made to the page. Try to avoid relying on positions.</li>
<li><strong>Use attributes</strong> - The best XPaths use the classname property or id property of an element or its parent.</li>
<li><strong>No Array Results</strong> - The XPath must always return a unique element. If an array of elements are returned, it will not work.</li>
<li><strong>Watch the Console</strong> - After you enable debugging the console provides useful error messages. This helps in identifying the problem.</li>
<li><strong>Read Examples</strong> - It is always best to check the huge <a href="http://wedata.net/databases/AutoPagerize/items.json">SITEINFO database</a> to understand how other users have tackled similar or tricky sites.</li>
</ol>
<p>For the site we were using as an example, the following code should work:</p>
<div>
<textarea name="code" class="JScript:nogutter" cols="60" rows="10">
   {
      pageElement: "\/\/table[contains(@class,\"ViewArticlePanel\")]",
      url: "^http:\/\/www\\.adobetutorialz\\.com\/articles",
      nextLink: "\/\/div[@class=\"ArticleNavigation\"]\/a[contains(text(),\"Next »\")]",
      exampleUrl: "http://www.adobetutorialz.com/articles/2751/1/Professional-Web-Layout-for-Business-Solutions"
    },

    </textarea>
</div>
<p>Hope this gives you enough information on Autopagerize and improves your browsing experience!</p>
<div class="socm_link">
<p class="bookm_links"> Bookmark this to      <a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F11%2F17%2Fforget-pages-with-autopagerize%2F&#038;title=Forget+Pages+with+Autopagerize" id="socialm_del.icio.us" title="Submit this post to del.icio.us">del.icio.us</a> |       <a href="http://digg.com/submit?phase=2&#038;url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F11%2F17%2Fforget-pages-with-autopagerize%2F&#038;title=Forget+Pages+with+Autopagerize" id="socialm_Digg" title="Submit this post to Digg">Digg</a> |       <a href="http://furl.net/storeIt.jsp?u=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F11%2F17%2Fforget-pages-with-autopagerize%2F&#038;t=Forget+Pages+with+Autopagerize" id="socialm_Furl" title="Submit this post to Furl">Furl</a> |       <a href=" http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F11%2F17%2Fforget-pages-with-autopagerize%2F&#038;T=Forget+Pages+with+Autopagerize" id="socialm_Netscape" title="Submit this post to Netscape">Netscape</a> |       <a href="  http://www.google.com/bookmarks/mark?op=edit&#038;bkmk=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F11%2F17%2Fforget-pages-with-autopagerize%2F&#038;title=Forget+Pages+with+Autopagerize" id="socialm_Google Bookmarks" title="Submit this post to Google Bookmarks">Google Bookmarks</a> |       <a href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F11%2F17%2Fforget-pages-with-autopagerize%2F" id="socialm_Technorati" title="Submit this post to Technorati">Technorati</a> |       <a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F11%2F17%2Fforget-pages-with-autopagerize%2F&#038;title=Forget+Pages+with+Autopagerize" id="socialm_reddit" title="Submit this post to reddit">reddit</a> |  </p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.arunrocks.com/blog/archives/2008/11/17/forget-pages-with-autopagerize/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Reading Hindu Online Made Better with Greasemonkey</title>
		<link>http://www.arunrocks.com/blog/archives/2008/07/19/reading-hindu-online-made-better-with-greasemonkey/</link>
		<comments>http://www.arunrocks.com/blog/archives/2008/07/19/reading-hindu-online-made-better-with-greasemonkey/#comments</comments>
		<pubDate>Sat, 19 Jul 2008 11:18:30 +0000</pubDate>
		<dc:creator>Arun bhai</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[greasemonkey]]></category>

		<category><![CDATA[productivity]]></category>

		<guid isPermaLink="false">http://www.arunrocks.com/blog/?p=131</guid>
		<description><![CDATA[Note this currently works only if you have Firefox installed
The Hindu is is one of the newspapers I have great respect for. I am allergetic to fresh newsprint, so I have no choice but to read their online edition even if I have subscribed to the print edition. But their website badly needs a redesign. [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Note this currently works only if you have Firefox installed</strong></p>
<p><a href="http://www.thehindu.com/">The Hindu</a> is is one of the newspapers I have great respect for. I am allergetic to fresh newsprint, so I have no choice but to read their online edition even if I have subscribed to the print edition. But their website badly needs a redesign. However, in this Web2.0 era you are not at the mercy of the site admins to do something about it. <em>You</em> can improve your browsing experience in 2 steps:</p>
<ol>
<li>
<p>Point your firefox to the <a href="https://addons.mozilla.org/en-US/firefox/addon/748">Greasemonkey add-on</a> page and install the add-on. Now restart Firefox before you go to step 2. Don&#8217;t worry all your open tabs will be restored.</p>
</li>
<li>
<p>Go to the <a href="http://userscripts.org/scripts/show/30273">Hindu Printer Redirect Script</a> and click on the <strong>Install this Script</strong> button</p>
</li>
</ol>
<p>Voila, start browsing Hindu, for example <a href="http://www.hindu.com/2008/07/19/01hdline.htm">this page</a> and enjoy the difference!</p>
<div class="socm_link">
<p class="bookm_links"> Bookmark this to      <a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F07%2F19%2Freading-hindu-online-made-better-with-greasemonkey%2F&#038;title=Reading+Hindu+Online+Made+Better+with+Greasemonkey" id="socialm_del.icio.us" title="Submit this post to del.icio.us">del.icio.us</a> |       <a href="http://digg.com/submit?phase=2&#038;url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F07%2F19%2Freading-hindu-online-made-better-with-greasemonkey%2F&#038;title=Reading+Hindu+Online+Made+Better+with+Greasemonkey" id="socialm_Digg" title="Submit this post to Digg">Digg</a> |       <a href="http://furl.net/storeIt.jsp?u=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F07%2F19%2Freading-hindu-online-made-better-with-greasemonkey%2F&#038;t=Reading+Hindu+Online+Made+Better+with+Greasemonkey" id="socialm_Furl" title="Submit this post to Furl">Furl</a> |       <a href=" http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F07%2F19%2Freading-hindu-online-made-better-with-greasemonkey%2F&#038;T=Reading+Hindu+Online+Made+Better+with+Greasemonkey" id="socialm_Netscape" title="Submit this post to Netscape">Netscape</a> |       <a href="  http://www.google.com/bookmarks/mark?op=edit&#038;bkmk=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F07%2F19%2Freading-hindu-online-made-better-with-greasemonkey%2F&#038;title=Reading+Hindu+Online+Made+Better+with+Greasemonkey" id="socialm_Google Bookmarks" title="Submit this post to Google Bookmarks">Google Bookmarks</a> |       <a href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F07%2F19%2Freading-hindu-online-made-better-with-greasemonkey%2F" id="socialm_Technorati" title="Submit this post to Technorati">Technorati</a> |       <a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.arunrocks.com%2Fblog%2Farchives%2F2008%2F07%2F19%2Freading-hindu-online-made-better-with-greasemonkey%2F&#038;title=Reading+Hindu+Online+Made+Better+with+Greasemonkey" id="socialm_reddit" title="Submit this post to reddit">reddit</a> |  </p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.arunrocks.com/blog/archives/2008/07/19/reading-hindu-online-made-better-with-greasemonkey/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
