By Eugene Schava
Has 4 other scripts.
// ==UserScript==
// @name Better Google for iPhone
// @namespace http://userscripts.org/scripts/show/16306
// @description Improves mobile view for iPhone for Google services
// @version 0.4.1
//
// @include http://www.google.com/m*
// @include http://mail.google.com/mail/*
// @include http://www.google.com/reader/m/*
// ==/UserScript==
(function() {
function onMainPageResize()
{
// height of all child items
var toolbarHeight = 35;
var iframeHeight = window.innerHeight - toolbarHeight;
changeCss(".pframe", "height", iframeHeight + "px");
}
function onGmailLoad()
{
// width of mail view
document.body.style.width = "";
// width of mail subject and body in list
changeCss(".tlsubj", "width", "");
changeCss(".tlsnippet", "width", "");
changeCss(".dropdown", "height", "");
changeCss(".button", "height", "");
}
function onReaderLoad()
{
// hide Google Reader logo
//changeCss(".logo", "display", "none");
// remove scrollbar from bottom
changeCss(".row", "padding", "0"); // was 3px at left and right
changeCss(".text", "padding", "8px 5px 8px 3px"); //was 8px 5px 8px 0
// enforce link "See original" opens in new window
xPathEnum("//a[text() = 'See original']", function(link) {link.target = '_new'; });
// make link "Keep unread" ajaxified
xPathEnum("//a[text() = 'Keep unread']",
function(link)
{
var url = link.href;
link.href = "javascript:void(0)";
link.addEventListener("click", function()
{
link.innerHTML = "Processing...";
link.removeAttribute("href");
GM_xmlhttpRequest({
method: 'GET',
url: url,
onload: function()
{
link.innerHTML = "OK";
}
});
return false;
}, false);
});
}
function xPathEnum(path, functor)
{
var query = document.evaluate(path, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0, length = query.snapshotLength; i < length; i++)
{
functor(query.snapshotItem(i));
}
}
function changeCss(clazz, element, value)
{
var cssRulesName = "cssRules";
for (var i = 0; i < document.styleSheets.length; i++)
{
try {
var cssRules = document.styleSheets[i][cssRulesName];
for (var j = 0; j < cssRules.length; j++)
{
if (cssRules[j].selectorText == clazz)
{
cssRules[j].style[element] = value;
}
}
} catch (e) { }
}
}
/*
// Code for testing
GM_addStyle('#JGRSmain { position: fixed; z-index: 32767; top: 0; right: 0; padding: 0 0 0 20px; min-height: 20px; background: 2px 2px url("chrome://browser/skin/page-livemarks.png") no-repeat; }');
var JGRSmain = document.createElement('div');
JGRSmain.setAttribute('id', 'JGRSmain');
document.body.appendChild(JGRSmain);
*/
if (document.domain == "mail.google.com")
{
onGmailLoad();
}
else
{
onReaderLoad();
onMainPageResize();
window.addEventListener("resize", onMainPageResize, true);
}
})();