Skip to content

Commit 0b35831

Browse files
committed
Import bootstrap to develop options page
1 parent e86a43b commit 0b35831

11 files changed

+9809
-36
lines changed

background.js

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,44 @@ function updateState(tabId, state) {
2828
// chrome.browserAction.setBadgeText({ text : "" });
2929
}
3030

31-
chrome.browserAction.onClicked.addListener(function(tab) {
3231

32+
document.addEventListener('DOMContentLoaded', function() {
33+
chrome.windows.getAll({
34+
'populate' : true
35+
}, function(wins) {
36+
wins.forEach(function(win) {
37+
win.tabs.forEach(function(tab) {
38+
if (tab != undefined && tab.url.indexOf('chrome') !== 0) {
39+
if (tab.highlighted) {
40+
Activity = tab.id;
41+
}
42+
updateState(tab.id, tab.status);
43+
}
44+
});
45+
});
46+
});
47+
});
48+
49+
chrome.tabs.onCreated.addListener(function(tab) {
50+
if (tab.highlighted) {
51+
Activity = tab.id;
52+
}
53+
updateState(tab.id, tab.status);
54+
});
55+
56+
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
57+
if (tab.highlighted) {
58+
Activity = tabId;
59+
}
60+
updateState(tabId, changeInfo.status);
61+
});
62+
63+
chrome.tabs.onActivated.addListener(function(info) {
64+
Activity = info.tabId;
65+
updateState();
66+
});
67+
68+
chrome.browserAction.onClicked.addListener(function(tab) {
3369
Activity = tab.id;
3470

3571
if (!TabState[Activity]) {
@@ -54,7 +90,7 @@ chrome.browserAction.onClicked.addListener(function(tab) {
5490
});
5591
updateState(Activity, "complete");
5692
} else {
57-
console.log("Tab all in unknown status : " + TabState[Activity]);
93+
console.log("Tab fall in unknown status : " + TabState[Activity]);
5894
}
5995

6096
// chrome.browserAction.setPopup({popup: "popup.html"});
@@ -65,24 +101,6 @@ chrome.browserAction.onClicked.addListener(function(tab) {
65101
// chrome.tabs.executeScript(tab.id, {file: 'script.js', allFrames: true});
66102
});
67103

68-
chrome.tabs.onCreated.addListener(function(tab) {
69-
if (tab.highlighted) {
70-
Activity = tab.id;
71-
}
72-
updateState(tab.id, tab.status);
73-
});
74-
75-
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
76-
if (tab.highlighted) {
77-
Activity = tabId;
78-
}
79-
updateState(tabId, changeInfo.status);
80-
});
81-
82-
chrome.tabs.onActivated.addListener(function(info) {
83-
Activity = info.tabId;
84-
updateState();
85-
});
86104

87105
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
88106
if (message.action == "capture") {
@@ -98,19 +116,3 @@ chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
98116
}
99117
});
100118

101-
document.addEventListener('DOMContentLoaded', function() {
102-
chrome.windows.getAll({
103-
'populate' : true
104-
}, function(wins) {
105-
wins.forEach(function(win) {
106-
win.tabs.forEach(function(tab) {
107-
if (tab != undefined && tab.url.indexOf('chrome') !== 0) {
108-
if (tab.highlighted) {
109-
Activity = tab.id;
110-
}
111-
updateState(tab.id, tab.status);
112-
}
113-
});
114-
});
115-
});
116-
});

0 commit comments

Comments
 (0)