File tree Expand file tree Collapse file tree 7 files changed +57
-146
lines changed
Expand file tree Collapse file tree 7 files changed +57
-146
lines changed Original file line number Diff line number Diff line change 1- // TODO: Move bg-test.js back here
2- try {
3- importScripts ( "bg-test.js" ) ;
4- } catch ( e ) {
5- console . error ( e ) ;
1+ chrome . runtime . onStartup . addListener ( initPlugin ) ;
2+ chrome . runtime . onInstalled . addListener ( initPlugin ) ;
3+ chrome . tabs . onActivated . addListener ( recheckPlugin ) ;
4+ let enabled = true ;
5+
6+ function onClick ( ) {
7+ if ( enabled ) {
8+ disable ( ) ;
9+ }
10+ else {
11+ enable ( ) ;
12+ }
13+ }
14+
15+ function initPlugin ( ) {
16+ chrome . storage . local . get ( 'dcr-enabled' , function ( res ) {
17+ enabled = res ;
18+ chrome . action . onClicked . addListener ( onClick ) ;
19+ chrome . runtime . onSuspend . addListener ( cleanupPlugin ) ;
20+ } ) ;
21+ }
22+
23+ function cleanupPlugin ( ) {
24+ chrome . storage . local . set ( { 'dcr-enabled' : enabled } ) ;
25+ }
26+
27+ function recheckPlugin ( ) {
28+ if ( enabled )
29+ enable ( ) ;
30+ else
31+ disable ( ) ;
32+ }
33+
34+ function enable ( ) {
35+ console . log ( "bg enable" ) ;
36+ enabled = true ;
37+ chrome . tabs . query ( { active : true , currentWindow : true } , function ( tabs ) {
38+ chrome . tabs . sendMessage ( tabs [ 0 ] . id , { message : 'dcr-enable' } ) ;
39+ } ) ;
40+ chrome . action . setIcon ( { path : 'icon-on.png' } ) ;
41+ chrome . action . setTitle ( { title : 'DataChartRenderer - enabled' } ) ;
42+ }
43+
44+ function disable ( ) {
45+ console . log ( "bg disable" ) ;
46+ enabled = false ;
47+ chrome . tabs . query ( { active : true , currentWindow : true } , function ( tabs ) {
48+ chrome . tabs . sendMessage ( tabs [ 0 ] . id , { message : 'dcr-disable' } ) ;
49+ } ) ;
50+ chrome . action . setIcon ( { path : 'icon-off.png' } ) ;
51+ chrome . action . setTitle ( { title : 'DataChartRenderer - disabled' } ) ;
652}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 22let enabled = true ;
33let limit = 5000 ;
44chrome . runtime . onMessage . addListener (
5- function ( request ) {
5+ function ( request , sender , sendResponse ) {
66 if ( request . message === "dcr-enable" ) {
77 enabled = true ;
8- window . hardRowLimit = + request . limit ;
9- console . log ( "DCR Enabled with limit " , request . limit ) ;
108 }
119 else if ( request . message === "dcr-disable" ) {
1210 enabled = false ;
13- console . log ( "DCR Stop" ) ;
1411 }
1512 }
1613) ;
Original file line number Diff line number Diff line change 33 "version" : " 0.0.1" ,
44 "manifest_version" : 3 ,
55 "description" : " This extension dynamically rendering potential chart representations of found CSV files in a popup." ,
6- "icons" : { "32" : " favicon.ico" },
7- "action" : {
8- "default_popup" : " popup/popup.html" ,
9- "default_icon" : " icon-on.png"
10- },
6+ "icons" : { "32" : " icon-on.png" },
7+ "action" : {},
118 "content_scripts" : [
129 {
1310 "matches" : [
2623 "run_at" : " document_end"
2724 }
2825 ],
26+ "background" : {
27+ "service_worker" : " background.js"
28+ },
2929 "permissions" : [
3030 " activeTab" ,
3131 " scripting" ,
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments