-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
56 lines (50 loc) · 1.98 KB
/
Copy pathpopup.js
File metadata and controls
56 lines (50 loc) · 1.98 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
47
48
49
50
51
52
53
54
55
56
// Popup script for DeleteThing
document.addEventListener('DOMContentLoaded', async () => {
try {
// Get the current active tab
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
const statusDiv = document.getElementById('status');
const statusText = document.getElementById('status-text');
// Check if the current tab is on a supported site
const supportedSites = [
{
pattern: /vercel\.com\/[^\/]+\/[^\/]+\/settings/,
name: 'Vercel'
},
{
pattern: /app\.netlify\.com\/projects\/[^\/]+\/configuration\/general/,
name: 'Netlify'
},
{
pattern: /dash\.cloudflare\.com\/[^\/]+\/pages\/view\/[^\/]+\/settings\/production/,
name: 'Cloudflare Pages'
},
{
pattern: /dash\.cloudflare\.com\/[^\/]+\/workers\/services\/view\/[^\/]+\/production\/settings/,
name: 'Cloudflare Workers'
}
];
let isSupported = false;
let siteName = '';
for (const site of supportedSites) {
if (site.pattern.test(tab.url)) {
isSupported = true;
siteName = site.name;
break;
}
}
if (isSupported) {
statusDiv.className = 'status active';
statusText.textContent = `Active on ${siteName}`;
} else {
statusDiv.className = 'status inactive';
statusText.textContent = 'Not active on this page';
}
} catch (error) {
console.error('Error in popup:', error);
const statusDiv = document.getElementById('status');
const statusText = document.getElementById('status-text');
statusDiv.className = 'status inactive';
statusText.textContent = 'Error checking page status';
}
});