Skip to content

Instantly share code, notes, and snippets.

@anandkunal
Created March 8, 2010 07:03
Show Gist options
  • Save anandkunal/324954 to your computer and use it in GitHub Desktop.
Save anandkunal/324954 to your computer and use it in GitHub Desktop.
Gmail Pagination Hack
// 1: older page for all mail
49: function() {
currentPage = GrabCurrentAllMailPage();
if (currentPage >= 2) {
window.location.hash = "#all/p" + (currentPage-1);
}
},
// 2: newer page for all mail
50: function() {
currentPage = GrabCurrentAllMailPage();
if (currentPage)
{
window.location.hash = "#all/p" + (currentPage+1);
}
else
{
window.location.hash = "#all/p2";
}
}
// Check the url for a pagination link - if you see /p# extract the #
// I should get a bit smarter and check the current page to do inbox routing
function GrabCurrentAllMailPage() {
var pageArray = window.location.hash.match(/^(.*)(\/)(p)([0-9]+)(.*)$/);
// If there is no hash, or the regex fails, then test for properties
if (pageArray)
{
if (pageArray.length != 6) {
return 1;
}
else {
return parseInt(pageArray[4]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment