Skip to content

zapper-content.js: fix duplicate firing#323

Merged
0xCUB3 merged 1 commit into0xCUB3:mainfrom
owlsy:wblock-fix-duplicate-firing-zapper
Apr 7, 2026
Merged

zapper-content.js: fix duplicate firing#323
0xCUB3 merged 1 commit into0xCUB3:mainfrom
owlsy:wblock-fix-duplicate-firing-zapper

Conversation

@owlsy
Copy link
Copy Markdown
Contributor

@owlsy owlsy commented Apr 6, 2026

  • Resolve attaching three handlers that all trigger for a single tap, which onChild may run multiple times.
  • Noticed behaviour when using "addManualRuleFromPrompt()", causing the prompt to appear twice on macOS when it should only be once.
  • Kept 'click' as it works in iOS Safari, macOS Safari, and for accessibility (keyboard activation).

Have not been able to test these changes, however, as I am unable to find a way to modify or overwrite Extension Scripts.

Resolve attaching three handlers
that all trigger for a single tap,
which onChild may run multiple times.

Noticed behaviour when using
"addManualRuleFromPrompt()",
causing the prompt to appear twice
on macOS when it should only be once.

Kept 'click' as it works in iOS Safari,
macOS Safari, and for accessibility
(keyboard activation).
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request simplifies event handling in zapper-content.js by removing redundant pointerup and touchend event listeners from several UI buttons, including the undo, manual rule, done, parent, child, and hide buttons. A review comment suggests refactoring the associated event handler functions to use the existing interceptEvent helper to reduce code duplication and improve maintainability.

I am having trouble creating individual review comments. Click here to see my feedback.

wBlock Scripts (iOS)/Resources/zapper-content.js (436-437)

medium

While you're fixing the multiple event firing, I noticed that the event handlers for the buttons (onUndo, onManualRule, onDone, onParent, onChild, onHide) all duplicate logic for stopping event propagation.

There's an existing helper function interceptEvent at line 804 that does exactly this.

You could refactor these handlers to use interceptEvent to reduce code duplication and improve readability.

For example, onUndo could be simplified to:

const onUndo = (e) => {
  interceptEvent(e);
  undoLastZap().catch(() => {});
};

This would apply to all the other button handlers as well.

@0xCUB3
Copy link
Copy Markdown
Owner

0xCUB3 commented Apr 7, 2026

Looks good to me. This keeps the path for Safari and accessibility, and removes the duplicate and handlers that were causing repeat firing.

@0xCUB3 0xCUB3 merged commit 8812e13 into 0xCUB3:main Apr 7, 2026
0 of 2 checks passed
@owlsy owlsy deleted the wblock-fix-duplicate-firing-zapper branch April 7, 2026 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants