File tree Expand file tree Collapse file tree 9 files changed +67
-133
lines changed
Expand file tree Collapse file tree 9 files changed +67
-133
lines changed Original file line number Diff line number Diff line change 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' } ) ;
52+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -3,14 +3,11 @@ let enabled = true;
33let limit = 5000 ;
44chrome . runtime . onMessage . addListener (
55 function ( request , sender , sendResponse ) {
6- if ( request . message === "start " ) {
7- this . enabled = true ;
6+ if ( request . message === "dcr-enable " ) {
7+ enabled = true ;
88 }
9- else if ( request . message === "stop" ) {
10- this . enabled = false ;
11- }
12- else if ( request . message === "limit" ) {
13- window . hardRowLimit = + request . value ;
9+ else if ( request . message === "dcr-disable" ) {
10+ enabled = false ;
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.html"
9- },
6+ "icons" : { "32" : " icon-on.png" },
7+ "action" : {},
108 "content_scripts" : [
119 {
1210 "matches" : [
2422 "css" : [" content/main.css" ],
2523 "run_at" : " document_end"
2624 }
25+ ],
26+ "background" : {
27+ "service_worker" : " background.js"
28+ },
29+ "permissions" : [
30+ " activeTab" ,
31+ " scripting" ,
32+ " storage" ,
33+ " tabs"
2734 ]
2835}
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments