-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3b9445f
Showing
11 changed files
with
324 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// Copyright (c) 2012 by Nick Simmonds. All rights reserved. | ||
|
||
var gMailUrl = "https://mail.google.com/?view=cm&fs=1&tf=1&source=mailto&to="; | ||
var gMailSub = "&su="; | ||
var yMailUrl = "http://compose.mail.yahoo.com?to="; | ||
var lMailUrl = "http://mail.live.com/?rru=compose&to="; | ||
var owaHTTP = localStorage["owaUrl"]; | ||
var owaUrl = "https://"+owaHTTP+"/owa/?ae=Item&a=New&t=IPM.Note&to="; | ||
var subject = "&subject="; | ||
|
||
//Context menu entry for Gmail fires this block | ||
function clickHandleGmail(){ | ||
// info starts out undefined, so this returns the whole function | ||
// when the context menu item is clicked | ||
return function mailToGoogle (info) { | ||
var link = info.linkUrl; | ||
link = link.replace("mailto:",gMailUrl); | ||
link = link.replace("?subject=","&su="); | ||
window.open(link); | ||
} | ||
} | ||
|
||
//same as the previous block, but for Yahoo! | ||
function clickHandleYmail() { | ||
return function mailToYahoo (info) { | ||
var link = info.linkUrl; | ||
link = link.replace("mailto:",yMailUrl); | ||
link = link.replace("?subject=",subject); | ||
window.open(link); | ||
} | ||
} | ||
|
||
function clickHandleLmail() { | ||
return function mailToLive (info) { | ||
var link = info.linkUrl; | ||
link = link.replace("mailto:",lMailUrl); | ||
link = link.replace("?subject=",subject); | ||
window.open(link); | ||
} | ||
} | ||
|
||
function clickHandleOWA() { | ||
return function mailToOWA (info) { | ||
var link = info.linkUrl; | ||
link = link.replace("mailto:",owaUrl); | ||
link = link.replace("?subject=",subject); | ||
window.open(link); | ||
} | ||
} | ||
|
||
|
||
|
||
// create the context menu items | ||
|
||
function createMenuGmail() { | ||
if (localStorage["gmail"] === "true") { | ||
chrome.contextMenus.create({ | ||
"title" : "Send via Gmail", | ||
"contexts" :["link"], | ||
"onclick" : clickHandleGmail() | ||
}); | ||
}; | ||
}; | ||
|
||
function createMenuYahoo() { | ||
if (localStorage["yahoo"] === "true") { | ||
chrome.contextMenus.create({ | ||
"title" : "Send via Yahoo!", | ||
"contexts" : ["link"], | ||
"onclick" : clickHandleYmail() | ||
}); | ||
}; | ||
}; | ||
|
||
function createMenuLive() { | ||
if (localStorage["live"] === "true") { | ||
chrome.contextMenus.create({ | ||
"title" : "Send via Microsoft Live Mail", | ||
"contexts" : ["link"], | ||
"onclick" : clickHandleLmail() | ||
}); | ||
}; | ||
}; | ||
|
||
function createMenuOWA() { | ||
if (localStorage["owa"] === "true") { | ||
chrome.contextMenus.create({ | ||
"title" : "Send via OWA", | ||
"contexts" : ["link"], | ||
"onclick" : clickHandleOWA() | ||
}); | ||
}; | ||
}; | ||
|
||
createMenuGmail(); | ||
createMenuYahoo(); | ||
createMenuLive(); | ||
createMenuOWA(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright 2012 by Nick Simmonds, all rights reserved. http://it.nicksimmonds.com | ||
|
||
var gMailUrl = "https://mail.google.com/?view=cm&fs=1&tf=1&source=mailto&to="; | ||
var gMailSub = "&su="; | ||
var yMailUrl = "http://compose.mail.yahoo.com?to="; | ||
var lMailUrl = "http://mail.live.com/?rru=compose&to="; | ||
var owaHTTP = localStorage["owaUrl"]; | ||
var owaUrl = "https://"+owaHTTP+"/owa/?ae=Item&a=New&t=IPM.Note&to="; | ||
var subject = "&subject="; | ||
var url = ""; | ||
var toggle; | ||
var def; | ||
var mailUrl; | ||
|
||
// Send a request to the extension. Extension replies with a 4 character response | ||
chrome.extension.sendRequest({"localStorage" : "toggle"}, function(response){ | ||
// take the first two characters and assign them to toggle. Should be either "on" | ||
// or "no" | ||
toggle = response.substring(0,2); | ||
// assign the last character to def to determine the default mail client | ||
def = response.charAt(3); | ||
switch (def) { | ||
case "g": | ||
mailUrl = gMailUrl; | ||
// Gmail uses a different subject identifier | ||
subject = gMailSub; | ||
break; | ||
|
||
case "y": | ||
mailUrl = yMailUrl; | ||
break; | ||
|
||
case "l": | ||
mailUrl = lMailUrl; | ||
break; | ||
|
||
case "o": | ||
mailUrl = owaUrl; | ||
break; | ||
|
||
// use Gmail as the default option, just in case. | ||
default: | ||
mailUrl = gMailUrl; | ||
subject = gMailSub; | ||
} | ||
}); | ||
|
||
|
||
|
||
|
||
|
||
// note (for debugging/learning purposes) that the function above doesn't fire until | ||
// the script is fully loaded. This is clearly a bug. Luckily, the way the below | ||
// function is written, it doesn't take place until after the page is fully loaded. | ||
$("a").click(function() { | ||
if (toggle === "on") { | ||
var url = this.href; | ||
url = url.replace("mailto:",mailUrl); | ||
url = url.replace("?subject=",subject); | ||
$(this).attr("href",url); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"name": "Post Office", | ||
"version": "0.72", | ||
"manifest_version": 2, | ||
"options_page" : "preferences.html", | ||
"description": "Chrome email functions", | ||
"default_popup": "preferences.html", | ||
"browser_action": { | ||
"default_icon": "disicon.png", | ||
"default_title": "Post Office" | ||
}, | ||
"content_scripts": [ | ||
{ | ||
"matches": ["http://*/*"], | ||
"js": [ | ||
"jquery-1.7.2.min.js", | ||
"mailscripts.js" | ||
] | ||
} | ||
], | ||
"background" : { | ||
"scripts": [ | ||
"mail.js", | ||
"toggle.js" | ||
] | ||
}, | ||
|
||
"permissions": [ | ||
"contextMenus", | ||
"links", | ||
"http://*/*", | ||
"https://*/*" | ||
], | ||
|
||
"icons": { | ||
"16" : "minicon.png", | ||
"48" : "midicon.png", | ||
"128" : "bigicon.png" | ||
} | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) 2012 by Nick Simmonds. All rights reserved. | ||
|
||
// Saves options to localStorage | ||
function saveOptions() { | ||
document.getElementById("output").innerHTML = "Saving"; | ||
localStorage["gmail"] = document.getElementById("gmail").checked; | ||
localStorage["yahoo"] = document.getElementById("yahoo").checked; | ||
localStorage["live"] = document.getElementById("live").checked; | ||
localStorage["owa"] = document.getElementById("owa").checked; | ||
localStorage["owaUrl"] = document.getElementById("owaUrl").value; | ||
localStorage["default"] = document.getElementById("default").value; | ||
document.getElementById("output").innerHTML = "Saved! Please close and re-open Chrome to apply changes."; | ||
} | ||
// Restores page elements state to saved value from localStorage. | ||
function restoreOptions() { | ||
for (var x in localStorage) { | ||
if (localStorage[x] === "true") { | ||
document.getElementById(x).checked = true; | ||
} else if (localStorage[x] === "false") { | ||
document.getElementById(x).checked = false; | ||
} else if (x === "owaUrl") { | ||
document.getElementById(x).value = localStorage[x]; | ||
} else if (x === "default") { | ||
document.getElementById(x).value = localStorage[x]; | ||
} else continue; | ||
} | ||
} | ||
|
||
//add event listeners | ||
|
||
//this adds the button listener | ||
document.addEventListener('DOMContentLoaded', function () { | ||
document.querySelector('button').addEventListener('click', saveOptions); | ||
}); | ||
|
||
//this resets the options when the page is loaded | ||
document.addEventListener('DOMContentLoaded', restoreOptions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!--- Copyright 2012 by Nick Simmonds, all rights reserved | ||
Post Office icon used by permission from Amanda Slater via Creative Commons | ||
Royal Mail icon used by permission from PL Chadwick via Creative Commons | ||
---> | ||
|
||
<!DOCTYPE html> | ||
<head><title>Post Office Options page</title> | ||
<style type="text/css"> | ||
#owaUrl { | ||
width: 169px; | ||
} | ||
</style> | ||
</head> | ||
<script src="options.js"> | ||
</script> | ||
<body> | ||
<img src="bigicon.png" /> | ||
<p>Select the webmail providers you use:</p> | ||
<input type="checkbox" id="gmail" checked="yes" /> Gmail<br /> | ||
<input type="checkbox" id="yahoo" /> Yahoo! mail<br /> | ||
<input type ="checkbox" id="live" /> Microsoft Live mail<br /> | ||
<input type="checkbox" id="owa" /> Outlook Web Access - <input type="text" id="owaUrl" value="Enter OWA address here" /><br /> | ||
<p>Select your primary webmail. This will be the default when the Post Office icon is toggled on.</p> | ||
<select id="default"> | ||
<option value="g">Gmail</option> | ||
<option value="y">Yahoo!</option> | ||
<option value="l">Live</option> | ||
<option value="o">OWA</option> | ||
</select> | ||
<p id="output"></p> | ||
<br> | ||
<button>Save</button> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) 2012 by Nick Simmonds. All rights reserved. | ||
|
||
function setStorage() { | ||
if (localStorage["toggle"] === null) { | ||
localStorage["toggle"] === "no"; | ||
} | ||
} | ||
|
||
function setIcon() { | ||
if (localStorage["toggle"] === "on") { | ||
chrome.browserAction.setIcon({path:"midicon.png"}); | ||
} else { | ||
chrome.browserAction.setIcon({path:"disicon.png"}); | ||
} | ||
} | ||
|
||
function toggle() { | ||
if (localStorage["toggle"] === "on") { | ||
chrome.browserAction.setIcon({path:"disicon.png"}); | ||
localStorage["toggle"] = "no"; | ||
} else { | ||
chrome.browserAction.setIcon({path:"midicon.png"}); | ||
localStorage["toggle"] = "on"; | ||
} | ||
} | ||
|
||
setStorage(); | ||
setIcon(); | ||
|
||
// swap the icon whenever it is clicked, then change the status of toggle. | ||
// Then, relaod the page to reload scripts. | ||
chrome.browserAction.onClicked.addListener(function (tab) { | ||
if (localStorage["toggle"] === "on") { | ||
chrome.browserAction.setIcon({path:"disicon.png"}); | ||
localStorage["toggle"] = "no"; | ||
} else { | ||
chrome.browserAction.setIcon({path:"midicon.png"}); | ||
localStorage["toggle"] = "on"; | ||
}; | ||
}) | ||
|
||
//respond to any requests with the state of toggle | ||
function toggleReq (request, sender, sendResponse) { | ||
sendResponse(localStorage["toggle"]+" "+localStorage["default"]); | ||
} | ||
|
||
// calls the toggleReq function whenever a request is sent | ||
chrome.extension.onRequest.addListener(toggleReq); |