File tree Expand file tree Collapse file tree 4 files changed +45
-4
lines changed
Expand file tree Collapse file tree 4 files changed +45
-4
lines changed Original file line number Diff line number Diff line change 44 < meta charset ="utf-8 ">
55 < title > WebActivity Time Tracker</ title >
66 < link href ="style/webact.css " rel ="stylesheet "/>
7+ < script src ="scripts/webact.js "> </ script >
78</ head >
89< body >
9- < p > test</ p >
10+ < div id ="resultTable ">
11+ </ div >
1012</ body >
1113</ html >
Original file line number Diff line number Diff line change 2323 "scripts" : [" scripts/background.js" ],
2424 "persistent" : false
2525 },
26-
2726 "browser_action" : {
2827 "default_popup" : " index.html" ,
2928 "default_title" : " WebActivity Time Tracker" ,
Original file line number Diff line number Diff line change 1- chrome . browserAction . onClicked . addListener ( function ( ) {
2- } ) ;
1+ window . onload = function ( ) {
2+ window . timer = new WebTimer ( ) ;
3+ chrome . tabs . onActivated . addListener ( function ( info ) {
4+ chrome . tabs . get ( info . tabId , function ( tab ) {
5+ window . timer . addTab ( tab ) ;
6+ } ) ;
7+ } ) ;
8+ } ;
9+
10+ var WebTimer = function ( ) { } ;
11+
12+ WebTimer . prototype = {
13+ tabs : [ ] ,
14+ activeTab : { } ,
15+
16+ addTab : function ( tab ) {
17+ if ( this . isValidPage ( tab ) === true ) {
18+ if ( tab . id && ( tab . id != 0 ) ) {
19+ this . tabs = this . tabs || [ ] ;
20+ this . tabs . push ( tab . url ) ;
21+ this . activeTab = tab . url ;
22+ }
23+ }
24+ } ,
25+
26+ isValidPage : function ( tab ) {
27+ if ( ! tab || ! tab . url || ( tab . url . indexOf ( 'http:' ) == - 1 && tab . url . indexOf ( 'https:' ) == - 1 )
28+ || tab . url . indexOf ( 'chrome://' ) !== - 1
29+ || tab . url . indexOf ( 'chrome-extension://' ) !== - 1 )
30+ return false ;
31+ return true ;
32+ }
33+ } ;
Original file line number Diff line number Diff line change 1+ window . onload = function ( ) {
2+ var table = document . getElementById ( 'resultTable' ) ;
3+ var tabs = chrome . extension . getBackgroundPage ( ) . timer . tabs ;
4+ for ( var i = 0 ; i < tabs . length ; i ++ ) {
5+ var p = document . createElement ( 'p' ) ;
6+ p . innerText = tabs [ i ] ;
7+ table . appendChild ( p ) ;
8+ }
9+ } ;
You can’t perform that action at this time.
0 commit comments