-
Notifications
You must be signed in to change notification settings - Fork 1
/
popup.js
53 lines (46 loc) · 1.76 KB
/
popup.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
45
46
47
48
49
50
51
52
53
/*
*var port = chrome.extension.connect({name: "Sample Communication"});
*port.postMessage("Hi BackGround");
*port.onMessage.addListener(function(msg) {
* console.log(msg);
*}); */
/*
chrome.extension.onMessage.addListener(function(message, messageSender, sendResponse) {
// message is the message you sent, probably an object
// messageSender is an object that contains info about the context that sent the message
// sendResponse is a function to run when you have a response
tabList = message;
}); */
document.addEventListener('DOMContentLoaded', function () {
var tabList = [];
var bg = chrome.extension.getBackgroundPage();
var removedTab = Object.keys(bg.removedTabs);
for (x in bg.removedTabs) {
tabList[tabList.length] = bg.removedTabs[x];
}
if (tabList.length == 0) {
document.getElementById("entry-1").innerHTML = "Nothing to display :)";
}
for (var i = 0; i < tabList.length; i++) {
var idName = "entry-" + (i+1);
if (tabList.length < 5) {
document.getElementById(idName).href = tabList[i].url;
document.getElementById(idName).innerHTML = tabList[i].title;
} else {
document.getElementById(idName).href = tabList[tabList.length - 5 + i].url;
document.getElementById(idName).innerHTML = tabList[tabList.length - 5 + i].title;
}
}
});
document.addEventListener('DOMContentLoaded', function () {
var links = document.getElementsByTagName("a");
for (var i = 0; i < links.length; i++) {
(function () {
var ln = links[i];
var location = ln.href;
ln.onclick = function () {
chrome.tabs.create({active: true, url: location});
};
})();
}
});