-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
46 lines (31 loc) · 1.04 KB
/
background.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
chrome.browserAction.onClicked.addListener(function(tab) {
//Obtain clipboard text
var bgPage = chrome.extension.getBackgroundPage();
var cbHolder = bgPage.document.getElementById("cbHolder");
cbHolder.focus();
cbHolder.select();
bgPage.document.execCommand("paste");
var srcADDR = cbHolder.value;
if(srcADDR==""){
srcADDR = "Mt GreyLock";
}
//Replace spaces and newlines with '+', remove '#'s
srcADDR = srcADDR.replace(/[\s\n]+/g,'+');
srcADDR = srcADDR.replace(/\#/g,'');
//Departure time (next weekday)
//Build google maps route url
routeURL = "https://maps.google.com/maps?"
+ "saddr=" + srcADDR
+ "&daddr=" + localStorage["addrOne"]
+ "&t=m"; // map type for faster loading
chrome.tabs.create(
{"url": routeURL}
);
routeURL = "https://maps.google.com/maps?"
+ "saddr=" + srcADDR
+ "&daddr=" + localStorage["addrTwo"]
+ "&t=m"; // map type for faster loading
chrome.tabs.create(
{"url": routeURL}
);
});