@@ -67,61 +67,15 @@ const init = (() => {
6767
6868 loadCss ( styles ) ;
6969
70- const EXTENSION_ON_SVG = `
71- <svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-power"><path d="M12 2v10"/><path d="M18.4 6.6a9 9 0 1 1-12.77.04"/></svg>
72- ` ;
73-
74- const el = document . createElement ( 'button' ) ;
75- el . classList . add ( 'react-scan-extension-button' , 'react-scan-default-font' ) ;
76- el . innerHTML = EXTENSION_ON_SVG ;
77-
78- el . onclick = async ( ) => {
79- const isCSPRulesEnabled = await getCSPRulesState ( ) ;
80- const toolbarContent = document . getElementById ( 'react-scan-toolbar-content' ) ;
81-
82- if ( isCSPRulesEnabled ) {
83- // send message to the extension to disable the rules
84- await chrome . runtime . sendMessage ( {
85- type : 'react-scan:csp-rules-changed' ,
86- data : {
87- enabled : false ,
88- domain : window . location . origin ,
89- } ,
90- } ) ;
91- } else {
92- // send message to the extension to enable the rules
93- await chrome . runtime . sendMessage ( {
94- type : 'react-scan:csp-rules-changed' ,
95- data : {
96- enabled : true ,
97- domain : window . location . origin ,
98- } ,
99- } ) ;
100-
101- window . location . reload ( ) ;
102- }
103-
104- await new Promise ( ( resolve ) => {
105- if ( toolbarContent ) {
106- toolbarContent . style . opacity = isCSPRulesEnabled ? '0' : '1' ;
107- toolbarContent . style . pointerEvents = isCSPRulesEnabled ? 'none' : 'auto' ;
108- }
109-
110- setTimeout ( resolve , 400 ) ;
111- } ) ;
112- } ;
113-
11470 const isCSPRulesEnabled = await getCSPRulesState ( ) ;
11571 if ( isCSPRulesEnabled ) {
11672 setTimeout ( ( ) => {
11773 const toolbar = document . getElementById ( 'react-scan-toolbar' ) ;
11874 if ( toolbar ) {
119- toolbar . appendChild ( el ) ;
75+ // toolbar.appendChild(el);
12076 toolbar . style . opacity = '1' ;
12177 }
12278 } , 400 ) ;
123- } else {
124- document . documentElement . appendChild ( el ) ;
12579 }
12680 } ;
12781} ) ( ) ;
0 commit comments