File tree Expand file tree Collapse file tree 3 files changed +47
-3
lines changed
Expand file tree Collapse file tree 3 files changed +47
-3
lines changed Original file line number Diff line number Diff line change 11import browser from "webextension-polyfill" ;
22
3- console . log ( "Hello from the background! " ) ;
3+ console . log ( "Start background script " ) ;
44
55browser . runtime . onInstalled . addListener ( ( details ) => {
66 console . log ( "Extension installed:" , details ) ;
Original file line number Diff line number Diff line change 33 "{{firefox}}.manifest_version" : 2 ,
44 "name" : " Web Activity Time Tracker" ,
55 "short_name" : " Web Tracker" ,
6- "version" : " 1.7.2 " ,
7- "description" : " Track and limit time your activity in the browser every day." ,
6+ "version" : " 2.0.0 " ,
7+ "description" : " Track and limit time your activity in the browser every day. Control how much time you spend on websites. " ,
88 "options_page" : " src/options.html" ,
99 "icons" : {
1010 "16" : " src/icons/16x16.png" ,
2727 " https://www.netflix.com/*"
2828 ],
2929 "offline_enabled" : true ,
30+ "content_scripts" : [
31+ {
32+ "matches" : [" *://*/*" ],
33+ "js" : [" src/tracker.ts" ],
34+ "all_frames" : true ,
35+ "run_at" : " document_start"
36+ }
37+ ],
3038 "background" : {
3139 "{{chrome}}.service_worker" : " src/background.ts" ,
3240 "{{firefox}}.scripts" : [" src/background.ts" ]
Original file line number Diff line number Diff line change 1+ import Browser from 'webextension-polyfill' ;
2+ import { isValidPage } from './compositions/valid-page' ;
3+ import { extractHostname } from './compositions/extract-hostname' ;
4+
5+ export async function initTracker ( ) {
6+ const window = await Browser . windows . getLastFocused ( { populate : true } ) ;
7+ if ( window . focused ) {
8+ const activeTab = window . tabs ?. find ( t => t . active === true ) ;
9+ if ( isValidPage ( activeTab ) ) {
10+ var activeUrl = extractHostname ( activeTab ?. url ) ;
11+ var tab = activity . getTab ( activeUrl ) ;
12+ if ( tab === undefined ) {
13+ activity . addTab ( activeTab ) ;
14+ }
15+
16+ if ( activity . isInBlackList ( activeUrl ) ) {
17+ chrome . action . setBadgeBackgroundColor ( { color : '#fdb8b8' } )
18+ chrome . action . setBadgeText ( {
19+ tabId : activeTab . id ,
20+ text : 'n/a'
21+ } ) ;
22+ } else {
23+ if ( tab !== undefined ) {
24+ if ( currentTab !== tab . url ) {
25+ activity . setCurrentActiveTab ( tab . url ) ;
26+ }
27+ chrome . idle . queryState ( parseInt ( setting_interval_inactivity ) , function ( state ) {
28+ if ( state === 'active' ) {
29+ mainTRacker ( activeUrl , tab , activeTab ) ;
30+ } else checkDOM ( state , activeUrl , tab , activeTab ) ;
31+ } ) ;
32+ }
33+ }
34+ }
35+ } else activity . closeIntervalForCurrentTab ( ) ;
36+ }
You can’t perform that action at this time.
0 commit comments