| 12345678910111213141516171819202122232425262728293031323334 |
- chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
- if (request.action === "clearCookies") {
- const url = request.url;
-
- chrome.cookies.getAll({ url }, (cookies) => {
- if (cookies.length === 0) {
- sendResponse({ success: true, message: "No cookies found for this site" });
- return;
- }
- let clearedCount = 0;
- cookies.forEach((cookie) => {
- chrome.cookies.remove({
- url,
- name: cookie.name
- }, () => {
- clearedCount++;
- if (clearedCount === cookies.length) {
- sendResponse({
- success: true,
- message: `Cleared ${cookies.length} cookies`
- });
- }
- });
- });
-
- // Handle case where we need to wait for async operations
- return true;
- });
-
- // Indicate we want to send response asynchronously
- return true;
- }
- });
|