-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
23 lines (22 loc) · 776 Bytes
/
Copy pathbackground.js
File metadata and controls
23 lines (22 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// ============================================
// FLATICON EXTRACTOR - BACKGROUND SCRIPT (SERVICE WORKER)
// Handles cross-origin requests to bypass CORS
// ============================================
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.action === "fetchSVG") {
fetch(message.url)
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.text();
})
.then(text => {
sendResponse({ success: true, data: text });
})
.catch(error => {
sendResponse({ success: false, error: error.message });
});
return true; // Keep message channel open for asynchronous response
}
});