Force HTTPS for GMail, GCal, and GDocs

By Anmar Mansur Last update Aug 18, 2007 — Installed 2,912 times. Daily Installs: 0, 0, 0, 1, 2, 0, 0, 29, 14, 3, 5, 7, 3, 5, 0, 3, 0, 0, 0, 2, 3, 1, 0, 6, 1, 1, 3, 1, 0, 2, 2, 3
// ==UserScript==
// @name           Force HTTPS for GMail, GCal, and GDocs
// @description    Modify Google corner bookmarks to use HTTPS for GMail, GCal, and GDocs
// @include        http://*.google.com/*
// ==/UserScript==

var link;
var gbar = document.evaluate("//div[@id='gbar']", document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
if (gbar) {
	link = document.evaluate(".//a[starts-with(@href, 'http://mail.google.com/mail')]", gbar, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
	link.href = link.href.replace(/^http:\/\//, "https://");
	link = document.evaluate(".//a[starts-with(@href, 'http://www.google.com/calendar')]", gbar, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
	link.href = link.href.replace(/^http:\/\//, "https://");
	link = document.evaluate(".//a[starts-with(@href, 'http://docs.google.com/')]", gbar, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
	link.href = link.href.replace(/^http:\/\//, "https://");
}