-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
26 lines (26 loc) · 1.12 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
// background.js
//message listener
chrome.runtime.onMessage.addListener(function(request, sender) {
if (request.type == "findItem") {
//updates the tab to the item url
chrome.tabs.update(null, { url: request.url });
} else if (request.type == "goToShop") {
//SET TO THE PREVIEW NOW, NEEDS TO BE CHANGED TO THE ACTUAL SHOP LINK
//OTHERWISE THIS WILL NOT WORK
chrome.tabs.create({ url: "http://www.supremenewyork.com/shop/all"});
} else if (request.type == "refresh") {
//tries to go to the "view all" page of the shop
chrome.tabs.update(null, { url: request.url });
} else if (request.type == "checkout") {
chrome.tabs.update(null, "https://www.supremenewyork.com/checkout")
} else if (request.type == "goToUrl") {
//SET TO THE PREVIEW NOW, NEEDS TO BE CHANGED TO THE ACTUAL SHOP LINK
//OTHERWISE THIS WILL NOT WORK
chrome.tabs.create({ url: request.url });
} else if (request.type == "goToUrlSameTab") {
//SET TO THE PREVIEW NOW, NEEDS TO BE CHANGED TO THE ACTUAL SHOP LINK
//OTHERWISE THIS WILL NOT WORK
chrome.tabs.update(null, { url: request.url });
}
return true;
});