Skip to content

Commit 23057f3

Browse files
committed
Update URL matches patten in popup. Need to do the same for my background
1 parent b8634f2 commit 23057f3

File tree

11 files changed

+551
-737
lines changed

11 files changed

+551
-737
lines changed

Public/background.js

Lines changed: 55 additions & 111 deletions
Large diffs are not rendered by default.

Public/content.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,17 @@ function checkForElement(selector, callback, options = {}) {
5454
setTimeout(checkElement, config.initialDelay);
5555
}
5656

57-
// Watch for element changes in the DOM
57+
// watch changess
5858
class ElementWatcher {
5959
constructor() {
6060
this.watchList = new Map();
6161
this.isWatching = false;
6262
this.observer = null;
63-
this.processedScripts = new Set(); // Track scripts that have been processed
63+
this.processedScripts = new Set(); // track processed scripts
6464
}
6565

6666
watch(selector, callback, scriptId) {
67-
// Don't add duplicate watches for the same script
67+
// dont process the same script multiple times
6868
if (this.processedScripts.has(scriptId)) {
6969
return;
7070
}
@@ -123,17 +123,16 @@ class ElementWatcher {
123123
}
124124
}
125125

126-
// Create the ElementWatcher
126+
// create watcher (I need a init function)
127127
const elementWatcher = new ElementWatcher();
128-
const executedScripts = new Set(); // Track executed scripts
128+
const executedScripts = new Set();
129129

130130
// Get messages from the background
131131
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
132132
if (message.action === "waitForElements") {
133133
console.log("Received element-ready scripts:", message.scripts.length);
134134

135135
message.scripts.forEach((script) => {
136-
// Skip if script was already executed
137136
if (executedScripts.has(script.id)) {
138137
return;
139138
}
@@ -142,7 +141,6 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
142141
checkForElement(
143142
script.waitForSelector,
144143
() => {
145-
// Mark as executed before sending message to prevent race conditions
146144
executedScripts.add(script.id);
147145
chrome.runtime.sendMessage({
148146
action: "elementFound",
@@ -168,7 +166,7 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
168166
return true;
169167
});
170168

171-
// Notify the background script when the content script is loaded
169+
// Notif
172170
chrome.runtime.sendMessage({
173171
action: "contentScriptReady",
174172
url: window.location.href,

Public/dashboard.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,7 @@ <h1>CodeTweak</h1>
215215
<th scope="col">Actions</th>
216216
</tr>
217217
</thead>
218-
<tbody id="scriptsList">
219-
<!-- Script rows will be populated dynamically -->
220-
</tbody>
218+
<tbody id="scriptsList"></tbody>
221219
</table>
222220
</div>
223221

0 commit comments

Comments
 (0)