From 1da915ff1388fab211738b2ffc58f3f14811b53c Mon Sep 17 00:00:00 2001 From: Wesley Branton Date: Tue, 25 Jun 2019 10:20:52 -0400 Subject: [PATCH 1/7] Removed unwanted developer log --- firefox/background.js | 1 - 1 file changed, 1 deletion(-) diff --git a/firefox/background.js b/firefox/background.js index 9ad38fb..9a5a5af 100644 --- a/firefox/background.js +++ b/firefox/background.js @@ -18,7 +18,6 @@ function handleIncomplete(tabId, changeInfo, tabInfo) { // Handle tab that will not lose parameters function handleComplete(tabId, changeInfo, tabInfo) { - console.log("Running"); removeHandlers(); } From fd67f5c4a736c8a84b873b7171b219cb095ded09 Mon Sep 17 00:00:00 2001 From: Wesley Branton Date: Tue, 25 Jun 2019 10:30:26 -0400 Subject: [PATCH 2/7] Patched bug #5 --- firefox/background.js | 13 ++++++++++++- firefox/manifest.json | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/firefox/background.js b/firefox/background.js index 9a5a5af..e437a05 100644 --- a/firefox/background.js +++ b/firefox/background.js @@ -38,9 +38,20 @@ function listenMessage(message) { } } +// Opens tab +function openTab(requestDetails) { + var link = requestDetails.url; + link = "/handler/sendmail.html" + link.slice(link.indexOf("?to"),link.length); + browser.tabs.create({ + url:link + }); + return {cancel: true}; +} + let data = browser.storage.local.get(); data.then(verify); var tmpUrl; const filter = {urls:["*://outlook.live.com/mail/deeplink/compose", "*://outlook.office.com/mail/deeplink/compose"]}; -chrome.runtime.onMessage.addListener(listenMessage); \ No newline at end of file +chrome.runtime.onMessage.addListener(listenMessage); +browser.webRequest.onBeforeRequest.addListener(openTab,{urls:["*://outlook.send/*"]},["blocking"]); \ No newline at end of file diff --git a/firefox/manifest.json b/firefox/manifest.json index fb0bc76..800b61c 100644 --- a/firefox/manifest.json +++ b/firefox/manifest.json @@ -31,12 +31,12 @@ "protocol_handlers": [{ "protocol": "mailto", "name": "Outlook.com", - "uriTemplate": "/handler/sendmail.html?to=%s" + "uriTemplate": "https://outlook.send/?to=%s" }], "background": { "scripts": ["background.js"] }, - "permissions": ["storage","tabs"] + "permissions": ["storage","tabs","webRequest","webRequestBlocking","*://outlook.send/*"] } \ No newline at end of file From 8536fd5b2734c394f99e243e6adf995fe7ede9b2 Mon Sep 17 00:00:00 2001 From: Wesley Branton Date: Tue, 25 Jun 2019 11:04:06 -0400 Subject: [PATCH 3/7] Optimized link generation The URL for the Outlook service is now generated before the new tab is created. This will prevent users who have selected "Don't ask again" from seeing the service selection screen load momentarily. --- firefox/background.js | 42 ++++++++++++++++++++++++++++++++------- firefox/handler/script.js | 19 ++---------------- 2 files changed, 37 insertions(+), 24 deletions(-) diff --git a/firefox/background.js b/firefox/background.js index e437a05..5e0a875 100644 --- a/firefox/background.js +++ b/firefox/background.js @@ -27,8 +27,8 @@ function removeHandlers() { browser.tabs.onUpdated.removeListener(handleComplete); } -// Message handler -function listenMessage(message) { +// Saves message data if the user needs to login +function saveMessage(message) { if (message.code == 'create-handler') { // Create required handlers browser.tabs.onUpdated.addListener(handleIncomplete, filter); @@ -38,20 +38,48 @@ function listenMessage(message) { } } -// Opens tab -function openTab(requestDetails) { - var link = requestDetails.url; - link = "/handler/sendmail.html" + link.slice(link.indexOf("?to"),link.length); +// Opens new tab +async function openTab(requestDetails) { + var params = await getParameters(requestDetails.url); + var base = await getBase(); + var link = base + params; browser.tabs.create({ url:link }); + saveMessage({'code':'create-handler','msg':[link,params]}) return {cancel: true}; } +// Converts Firefox mailto string into standard URL parameters +function getParameters(url) { + var decodedURL, to, formatURL; + decodedURL = decodeURIComponent(url); + decodedURL = decodedURL.slice(decodedURL.indexOf("mailto") + 7); + if (decodedURL.indexOf("?") >= 0) { + to = decodedURL.slice(0,decodedURL.indexOf("?")); + decodedURL = decodedURL.slice(decodedURL.indexOf("?") + 1); + formatURL = "?to=" + to + "&" + decodedURL; + } else { + to = decodedURL; + formatURL = "?to=" + to; + } + return formatURL; +} + +// Determines which Outlook service to go to +async function getBase() { + var data = await browser.storage.local.get(); + if (data.mode == 'live' || data.mode == 'office') { + return "https://outlook." + data.mode + ".com/mail/deeplink/compose"; + } else { + return "/handler/sendmail.html"; + } +} + let data = browser.storage.local.get(); data.then(verify); var tmpUrl; const filter = {urls:["*://outlook.live.com/mail/deeplink/compose", "*://outlook.office.com/mail/deeplink/compose"]}; -chrome.runtime.onMessage.addListener(listenMessage); +chrome.runtime.onMessage.addListener(saveMessage); browser.webRequest.onBeforeRequest.addListener(openTab,{urls:["*://outlook.send/*"]},["blocking"]); \ No newline at end of file diff --git a/firefox/handler/script.js b/firefox/handler/script.js index 78990eb..f2d7391 100644 --- a/firefox/handler/script.js +++ b/firefox/handler/script.js @@ -2,25 +2,10 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -// Converts Firefox mailto string into standard URL parameters -function createURL() { - var decodedURL, to, formatURL; - decodedURL = decodeURIComponent(window.location); - decodedURL = decodedURL.slice(decodedURL.indexOf("mailto") + 7); - if (decodedURL.indexOf("?") >= 0) { - to = decodedURL.slice(0,decodedURL.indexOf("?")); - decodedURL = decodedURL.slice(decodedURL.indexOf("?") + 1); - formatURL = "?to=" + to + "&" + decodedURL; - } else { - to = decodedURL; - formatURL = "?to=" + to; - } - return formatURL; -} - // Load email composition page function redirect(mode) { - var parameters = createURL(); + var parameters = decodeURIComponent(window.location); + parameters = parameters.slice(parameters.indexOf("?to="),parameters.length); var url = "https://outlook." + mode + ".com/mail/deeplink/compose" + parameters; if (!wait) { if (document.getElementById('doNotAsk').checked) { From 0f6ee0e2bce142f562f9518f6053e556791e6fb4 Mon Sep 17 00:00:00 2001 From: Wesley Branton Date: Tue, 25 Jun 2019 11:41:38 -0400 Subject: [PATCH 4/7] Fixed styling --- firefox/manifest.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/firefox/manifest.json b/firefox/manifest.json index 800b61c..af8ed8c 100644 --- a/firefox/manifest.json +++ b/firefox/manifest.json @@ -38,5 +38,11 @@ "scripts": ["background.js"] }, - "permissions": ["storage","tabs","webRequest","webRequestBlocking","*://outlook.send/*"] + "permissions": [ + "storage", + "tabs", + "webRequest", + "webRequestBlocking", + "*://outlook.send/*" + ] } \ No newline at end of file From d15cab1fa42ec82d4f7ae5ed2f1b574dc0062cca Mon Sep 17 00:00:00 2001 From: Wesley Branton Date: Tue, 25 Jun 2019 11:46:10 -0400 Subject: [PATCH 5/7] Changed version number --- firefox/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firefox/manifest.json b/firefox/manifest.json index af8ed8c..874b245 100644 --- a/firefox/manifest.json +++ b/firefox/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Outlook.com mailto", - "version": "2.0", + "version": "2.1", "description": "Add Outlook.com as a default email provider for all mailto links.", "author": "Wesley Branton", From 359f5da453b7c3ba817ab43ee01d114355343ef8 Mon Sep 17 00:00:00 2001 From: Wesley Branton Date: Tue, 25 Jun 2019 11:46:24 -0400 Subject: [PATCH 6/7] Added version 2.1 release notes --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 06533c6..268c93f 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,11 @@ To develop and test the extension, you need to open the "about:debugging" page i Further documentation about developing Firefox extensions can be found [here](https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/Your_first_WebExtension). ## Release Notes +### Version 2.1 +* **[FIXED]** Outlook now opens in a new tab +* **[FIXED]** The Outlook selection screen will not load if you have selected "Don't ask again" +* **[FIXED]** Optimized link generation + ### Version 2.0 * **[NEW]** Added support for outlook.office.com * **[FIXED]** Message prefill data is no longer lost at login page From e4facf8637010158b7bbc7cd239378d3197f1c94 Mon Sep 17 00:00:00 2001 From: Wesley Branton Date: Tue, 25 Jun 2019 11:51:51 -0400 Subject: [PATCH 7/7] Increased minimum version --- firefox/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firefox/manifest.json b/firefox/manifest.json index 874b245..b12f473 100644 --- a/firefox/manifest.json +++ b/firefox/manifest.json @@ -24,7 +24,7 @@ "browser_specific_settings": { "gecko": { "id": "outlook@computerwhiz", - "strict_min_version": "54.0" + "strict_min_version": "57.0" } },