Skip to content

Commit

Permalink
Improve disable-newtab-links scriptlet
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Feb 25, 2025
1 parent 7fb656b commit d41989e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/js/resources/scriptlets.js
Original file line number Diff line number Diff line change
Expand Up @@ -2222,8 +2222,8 @@ builtinScriptlets.push({
});
// https://github.com/uBlockOrigin/uAssets/issues/913
function disableNewtabLinks() {
document.addEventListener('click', function(ev) {
var target = ev.target;
document.addEventListener('click', ev => {
let target = ev.target;
while ( target !== null ) {
if ( target.localName === 'a' && target.hasAttribute('target') ) {
ev.stopPropagation();
Expand All @@ -2232,7 +2232,7 @@ function disableNewtabLinks() {
}
target = target.parentNode;
}
});
}, { capture: true });
}

/******************************************************************************/
Expand Down

0 comments on commit d41989e

Please sign in to comment.