@@ -28,8 +28,44 @@ function updateState(tabId, state) {
28
28
// chrome.browserAction.setBadgeText({ text : "" });
29
29
}
30
30
31
- chrome . browserAction . onClicked . addListener ( function ( tab ) {
32
31
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 ) {
33
69
Activity = tab . id ;
34
70
35
71
if ( ! TabState [ Activity ] ) {
@@ -54,7 +90,7 @@ chrome.browserAction.onClicked.addListener(function(tab) {
54
90
} ) ;
55
91
updateState ( Activity , "complete" ) ;
56
92
} else {
57
- console . log ( "Tab all in unknown status : " + TabState [ Activity ] ) ;
93
+ console . log ( "Tab fall in unknown status : " + TabState [ Activity ] ) ;
58
94
}
59
95
60
96
// chrome.browserAction.setPopup({popup: "popup.html"});
@@ -65,24 +101,6 @@ chrome.browserAction.onClicked.addListener(function(tab) {
65
101
// chrome.tabs.executeScript(tab.id, {file: 'script.js', allFrames: true});
66
102
} ) ;
67
103
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
- } ) ;
86
104
87
105
chrome . runtime . onMessage . addListener ( function ( message , sender , sendResponse ) {
88
106
if ( message . action == "capture" ) {
@@ -98,19 +116,3 @@ chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
98
116
}
99
117
} ) ;
100
118
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