fix image path and popup window

This commit is contained in:
A.R-M 2024-07-21 00:58:16 -04:00
parent 2573fbb24a
commit 125e384669
8 changed files with 114 additions and 10 deletions

View File

@ -0,0 +1,4 @@
chrome.runtime.onInstalled.addListener(() => {
console.log("Reject Cookies extension installed.");
});

View File

@ -3,8 +3,6 @@ chrome.storage.sync.get('selectors', (data) => {
'button[aria-label="reject"]',
'button[data-testid="reject"]',
'button[class*="reject"]'
// Add selectors as needed
];
function clickButton(selector) {

View File

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

Before

Width:  |  Height:  |  Size: 555 B

After

Width:  |  Height:  |  Size: 555 B

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -3,7 +3,7 @@
"name": "Reject Cookies",
"version": "1.0",
"description": "Automatically reject all cookie popups.",
"permissions": ["activeTab", "scripting"],
"permissions": ["activeTab", "storage", "scripting"],
"background": {
"service_worker": "background.js"
},
@ -13,6 +13,14 @@
"js": ["content.js"],
"run_at": "document_end"
}
]
],
"action": {
"default_popup": "popup.html",
"default_icon": {
"16": "images/icon16.png",
"48": "images/icon48.png",
"128": "images/icon128.png"
}
}
}

View File

@ -3,19 +3,75 @@
<head>
<title>Reject Cookies Settings</title>
<style>
body { width: 300px; font-family: Arial, sans-serif; }
.container { padding: 10px; }
textarea { width: 100%; height: 100px; }
button { margin-top: 10px; }
body {
width: 300px;
font-family: Arial, sans-serif;
padding: 10px;
box-sizing: border-box;
}
h2 {
font-size: 18px;
margin: 0;
padding-bottom: 10px;
border-bottom: 1px solid #ddd;
}
textarea {
width: calc(100% - 20px);
height: 100px;
padding: 10px;
box-sizing: border-box;
border: 1px solid #ddd;
border-radius: 4px;
}
button {
margin-top: 10px;
padding: 10px;
border: none;
background-color: #007bff;
color: white;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
}
button:hover {
background-color: #0056b3;
}
.status {
margin-top: 10px;
color: #28a745;
}
.instructions {
font-size: 14px;
color: #555;
margin-bottom: 10px;
}
.selectors-list {
margin-top: 10px;
}
.selectors-list ul {
list-style-type: none;
padding: 0;
}
.selectors-list li {
padding: 5px;
border-bottom: 1px solid #ddd;
}
</style>
</head>
<body>
<div class="container">
<h2>Reject Cookies Settings</h2>
<p>Enter selectors to reject cookies, one per line:</p>
<p class="instructions">
Enter CSS selectors for cookie rejection buttons. One per line.
<br>For example: <code>button[aria-label="reject"]</code>
</p>
<textarea id="selectors"></textarea>
<button id="save">Save</button>
<p id="status"></p>
<p id="status" class="status"></p>
<div class="selectors-list">
<h3>Current Selectors:</h3>
<ul id="selectors-list"></ul>
</div>
</div>
<script src="popup.js"></script>
</body>

View File

@ -0,0 +1,38 @@
document.addEventListener('DOMContentLoaded', () => {
const textarea = document.getElementById('selectors');
const saveButton = document.getElementById('save');
const status = document.getElementById('status');
const selectorsList = document.getElementById('selectors-list');
// Load existing selectors
chrome.storage.sync.get('selectors', (data) => {
const selectors = data.selectors || [];
textarea.value = selectors.join('\n');
updateSelectorsList(selectors);
});
// Save button click event
saveButton.addEventListener('click', () => {
const selectors = textarea.value.split('\n').map(s => s.trim()).filter(s => s.length > 0);
// Simple validation for selectors
if (selectors.length === 0) {
status.textContent = 'Please enter at least one selector.';
status.style.color = 'red';
return;
}
chrome.storage.sync.set({ selectors: selectors }, () => {
status.textContent = 'Selectors saved!';
status.style.color = '#28a745';
updateSelectorsList(selectors);
setTimeout(() => status.textContent = '', 2000);
});
});
// Update the list of selectors in the popup
function updateSelectorsList(selectors) {
selectorsList.innerHTML = selectors.map(selector => `<li>${selector}</li>`).join('');
}
});