Skip to content

Instantly share code, notes, and snippets.

@kjmkznr
Created December 3, 2010 00:23
Show Gist options
  • Save kjmkznr/726365 to your computer and use it in GitHub Desktop.
Save kjmkznr/726365 to your computer and use it in GitHub Desktop.
always https
if (location.href.substring(0,5) == 'http:') {
console.log(location.href);
console.log(location.host);
console.log(location.pathname);
old_url = location.href.substring(7);
if (m = old_url.match("(www\.)?google\.com/search(.*)")) {
param = m[2];
window.location = "https://encrypted.google.com/search".concat(param);
} else if (m = old_url.match("(www\.)?google\.com/webhp(.*)")) {
param = m[2];
window.location = "https://encrypted.google.com/webhp".concat(param);
} else if (m = old_url.match("(www\.)?google\.com/firefox/(.*)")) {
param = m[2];
window.location = "https://encrypted.google.com/webhp".concat(param);
} else if (m = old_url.match("(www\.)?google\.com/squared(.*)")) {
param = m[2];
window.location = "https://www.google.com/squared".concat(param);
} else if (m = old_url.match("(www\.)?google\.com/reader(.*)")) {
param = m[2];
window.location = "https://www.google.com/reader".concat(param);
} else if (m = old_url.match("codesearch\.google\.com/(.*)")) {
param = m[1];
window.location = "https://codesearch.google.com/".concat(param);
} else if (m = old_url.match("(www\.)?google.com/(.*)")) {
param = m[2];
window.location = "https://encrypted.google.com/".concat(param);
} else if (m = old_url.match("(www\.)?google.co\.[a-z][a-z]/(.*)")) {
param = m[2];
window.location = "https://encrypted.google.com/".concat(param);
} else if (m = old_url.match("code\.google\.com/(.*)") {
param = m[1];
window.location = "https://code.google.com/".concat(param);
} else {
return false;
}
}
{
"content_scripts": [
{
"js": [ "always_https.js" ],
"matches": [ "http://*.google.com/*", "http://*.google.co.jp/*" ],
"run_at": "document_start"
}
],
"description": "Always access on https.",
"name": "Always https",
"permissions": [ "tabs" ],
"version": "0.1"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment