|
|
@@ -0,0 +1,48 @@
|
|
|
+document.addEventListener('DOMContentLoaded', () => {
|
|
|
+ const clearButton = document.getElementById('clear-cookies');
|
|
|
+ const siteInfo = document.getElementById('site-info');
|
|
|
+ const status = document.getElementById('status');
|
|
|
+
|
|
|
+ // Get current active tab
|
|
|
+ chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
|
|
|
+ if (tabs[0]) {
|
|
|
+ const url = new URL(tabs[0].url);
|
|
|
+ const hostname = url.hostname;
|
|
|
+ siteInfo.textContent = `Current site: ${hostname}`;
|
|
|
+
|
|
|
+ // Store the URL for cookie clearing
|
|
|
+ clearButton.dataset.url = tabs[0].url;
|
|
|
+ } else {
|
|
|
+ siteInfo.textContent = "No active tab found";
|
|
|
+ clearButton.disabled = true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // Handle clear cookies button
|
|
|
+ clearButton.addEventListener('click', () => {
|
|
|
+ const url = clearButton.dataset.url;
|
|
|
+
|
|
|
+ if (!url) {
|
|
|
+ status.textContent = "Error: No URL found";
|
|
|
+ status.style.color = "red";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ status.textContent = "Clearing cookies...";
|
|
|
+ status.style.color = "black";
|
|
|
+
|
|
|
+ // Send message to background to clear cookies
|
|
|
+ chrome.runtime.sendMessage({
|
|
|
+ action: "clearCookies",
|
|
|
+ url: url
|
|
|
+ }, (response) => {
|
|
|
+ if (response && response.success) {
|
|
|
+ status.textContent = response.message;
|
|
|
+ status.style.color = "green";
|
|
|
+ } else {
|
|
|
+ status.textContent = "Error clearing cookies";
|
|
|
+ status.style.color = "red";
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+});
|