-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpanel.js
More file actions
46 lines (44 loc) · 1.47 KB
/
panel.js
File metadata and controls
46 lines (44 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Panel script - CSP compliant
console.log('Panel script loaded');
// Add error handling
window.addEventListener('error', (e) => {
console.error('Panel error:', e.error);
const root = document.getElementById('root');
if (root) {
root.innerHTML = `
<div style="padding: 20px; text-align: center;">
<h3>Error Loading Extension</h3>
<p>Please check the console for details</p>
<button id="reload-btn">Reload</button>
</div>
`;
// Add event listener properly (CSP compliant)
const reloadBtn = document.getElementById('reload-btn');
if (reloadBtn) {
reloadBtn.addEventListener('click', () => location.reload());
}
}
});
// Try to load the React app
try {
const script = document.createElement('script');
script.src = chrome.runtime.getURL('index.js');
script.onerror = () => {
console.error('Failed to load index.js');
const root = document.getElementById('root');
if (root) {
root.innerHTML = `
<div style="padding: 20px; text-align: center;">
<h3>Failed to Load App</h3>
<p>Extension files not found</p>
</div>
`;
}
};
script.onload = () => {
console.log('React app loaded successfully');
};
document.head.appendChild(script);
} catch (e) {
console.error('Error loading script:', e);
}