Skip to content

Commit d89cafc

Browse files
committed
refactor(extension): remove embedded toggle functionality
1 parent 47ed60b commit d89cafc

File tree

2 files changed

+1
-94
lines changed

2 files changed

+1
-94
lines changed

packages/extension/src/assets/css/styles.css

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,6 @@
22
font-family: Menlo, Consolas, Monaco, 'Liberation Mono', 'Lucida Console', monospace;
33
}
44

5-
.react-scan-extension-button {
6-
position: fixed;
7-
right: 24px;
8-
bottom: 24px;
9-
display: flex;
10-
align-items: center;
11-
justify-content: center;
12-
height: 39px;
13-
min-width: 39px;
14-
color: rgba(255, 255, 255, 0.5);
15-
background: rgba(0, 0, 0, 0.95);
16-
border: 1px solid rgba(255, 255, 255, 0.1);
17-
border-radius: 8px;
18-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
19-
pointer-events: auto;
20-
cursor: pointer;
21-
transition: all 300ms ease-in-out;
22-
opacity: 0;
23-
animation: fadeIn 300ms 300ms ease-in-out forwards;
24-
z-index: 2147483650;
25-
}
26-
27-
@keyframes fadeIn {
28-
from {
29-
opacity: 0;
30-
}
31-
32-
to {
33-
opacity: 1;
34-
}
35-
}
36-
37-
.react-scan-extension-button:hover {
38-
color: #fff;
39-
}
40-
415
#react-scan-toolbar {
426
flex-direction: row !important;
437
opacity: 0;
@@ -47,14 +11,3 @@
4711
#react-scan-toolbar #react-scan-toolbar-content {
4812
transition: opacity 300ms ease-in-out;
4913
}
50-
51-
#react-scan-toolbar .react-scan-extension-button {
52-
position: unset;
53-
margin-left: 4px;
54-
opacity: 1;
55-
animation: none;
56-
}
57-
58-
#react-scan-toolbar .react-scan-extension-button:hover {
59-
background: rgba(0, 0, 0, 0.95);
60-
}

packages/extension/src/content/index.ts

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)