-
Notifications
You must be signed in to change notification settings - Fork 1
/
background.js
31 lines (28 loc) · 894 Bytes
/
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
var obj;
fetch('countryName2.json')
.then(response => response.json())
.then(data => {
obj = data;
//console.log(myData);
chrome.contextMenus.onClicked.addListener(function (params, tab) {
for (var i = 0; i < obj.length; i++){
if (obj[i].name == params.selectionText){
chrome.tabs.create({url: 'https://www.kayak.com/travel-restrictions?&origin=' + obj[i].countryCode});
}
}
});
}
)
.catch(error => console.log(error));
chrome.runtime.onMessage.addListener(
function (request, sender, sendResponse) {
if (request.message === "open_new_tab") {
chrome.tabs.create({"url": request.url});
}
}
);
chrome.contextMenus.create({
id: "",
title: 'Using TravelToday searching %s',
contexts: ['selection'],
});