Skip to content

Commit 1aa0925

Browse files
committed
fix: update callback on existing detector singleton
If the detector singleton already exists and a new fireEvent callback is provided, update the callback. This handles the case where the detector is created without a callback and later called with one. Made-with: Cursor
1 parent d91b562 commit 1aa0925

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

injected/src/detectors/detections/youtube-ad-detection.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,8 +755,11 @@ export function runYoutubeAdDetection(config, logger, fireEvent) {
755755
return { detected: false, type: 'youtubeAds', results: [] };
756756
}
757757

758-
// If detector already exists, return its results (even if config is undefined)
758+
// If detector already exists, update callback if provided and return results
759759
if (detectorInstance) {
760+
if (fireEvent) {
761+
detectorInstance.onEvent = fireEvent;
762+
}
760763
return detectorInstance.getResults();
761764
}
762765

0 commit comments

Comments
 (0)