-
Notifications
You must be signed in to change notification settings - Fork 3
/
background.js
44 lines (41 loc) · 1.28 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
function autoSendSmsIfNotAnswer(dest, msg) {
var app_id = localStorage['app_id']
var access_token = localStorage['access_token']
var txn_ref = localStorage['txn_ref']
if (isEmpty(app_id) || isEmpty(access_token) || isEmpty(txn_ref)) {
return;
};
$.ajax({
type: "POST",
url: "https://secure.hoiio.com/open/voice/query_status",
data: ({
app_id: app_id,
access_token: access_token,
txn_ref: txn_ref
}),
success: function (result) {
if (result.status == 'success_ok') {
if (result.call_status_dest1 != 'answered') {
sendSmsMsg(dest, msg);
}
}
}
});
}
chrome.extension.onRequest.addListener(
function (request, sender, sendResponse) {
if (request.func == "autoSendSms") {
setTimeout(function () {
autoSendSmsIfNotAnswer(request.dest, request.msg);
}, 60000);
} else if (request.func == "addRemoveTab") {
addOnRemoveTabListener(request.tabId);
}
});
function addOnRemoveTabListener(msgTabId) {
chrome.tabs.onRemoved.addListener(function (tabid, removeInfo) {
if (tabid == msgTabId) {
localStorage['is_open_optiontab'] = false;
}
});
}