-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent_page.js
44 lines (40 loc) · 1.43 KB
/
event_page.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
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
var res;
if (message.type == "convert") {
res = {
isValid: false,
content: "*REQUIRED",
time: ""
};
if (message.post_name != "" && message.timestamp != "") {
chrome.tabs.query(
{active: true, currentWindow: true},
function(tabs) {
chrome.tabs.sendMessage(
tabs[0].id,
{name: message.post_name, timestamp: message.timestamp},
function(response) {
if (chrome.runtime.lastError) {
console.log("ERROR: " +
chrome.runtime.lastError.message);
} else {
res.isValid = response.isValid;
res.content = response.content;
res.time = response.time;
sendResponse(res);
}
}
);
}
);
} else {
sendResponse(res);
}
}
return true;
});
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
if (tab.url.indexOf('https://www.facebook.com') == 0) {
chrome.pageAction.show(tabId);
}
});