-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
29 lines (25 loc) · 1.01 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
chrome.browserAction.onClicked.addListener(function(tab) {
console.log("begin background stuff");
searches = ["- google search", 'gmail', "www.facebook.com", "www.reddit.com", "twitter.com", "www.youtube.com", ""];
for (var search of searches) {
chrome.history.search({text: search, maxResults: 300}, function(data) {
pages = [];
data.forEach(function(page) {
pages.push(page);
});
//send message to backend....
const yourUrl = "http://localhost:5000/user-api/postHistory";
var xhr = new XMLHttpRequest();
xhr.open("POST", yourUrl, true);
xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
xhr.send(JSON.stringify({
value: pages
}));
// Send a message to the active tab
/*chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
var activeTab = tabs[0];
chrome.tabs.sendMessage(activeTab.id, {"message": pages});
});*/
});
}
});