From 91ee5bdeae6981cc20038b6610ab5c16b58623cf Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Tue, 11 Jun 2024 07:44:43 -0400 Subject: [PATCH] Improve `prevent-addEventListener` scriptlet Related issue: https://github.com/uBlockOrigin/uBlock-issues/issues/3061#issuecomment-2159662039 --- assets/resources/scriptlets.js | 2 ++ platform/mv3/extension/_locales/zh_CN/messages.json | 2 +- src/_locales/be/messages.json | 2 +- src/_locales/eu/messages.json | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/assets/resources/scriptlets.js b/assets/resources/scriptlets.js index 54adfb623..da232b70a 100644 --- a/assets/resources/scriptlets.js +++ b/assets/resources/scriptlets.js @@ -1642,6 +1642,8 @@ function addEventListenerDefuser( const debug = shouldDebug(extraArgs); const targetSelector = extraArgs.elements || undefined; const elementMatches = elem => { + if ( targetSelector === 'window' ) { return elem === window; } + if ( targetSelector === 'document' ) { return elem === document; } if ( elem && elem.matches && elem.matches(targetSelector) ) { return true; } const elems = Array.from(document.querySelectorAll(targetSelector)); return elems.includes(elem); diff --git a/platform/mv3/extension/_locales/zh_CN/messages.json b/platform/mv3/extension/_locales/zh_CN/messages.json index ffbbf9c03..9195970cb 100644 --- a/platform/mv3/extension/_locales/zh_CN/messages.json +++ b/platform/mv3/extension/_locales/zh_CN/messages.json @@ -156,7 +156,7 @@ "description": "Label for a checkbox in the options page" }, "showBlockedCountLabel": { - "message": "在工具栏图标上显示已拦截的请求数", + "message": "在工具栏图标上显示拦截请求数", "description": "Label for a checkbox in the options page" } } diff --git a/src/_locales/be/messages.json b/src/_locales/be/messages.json index bb7a45850..ca1ee35bc 100644 --- a/src/_locales/be/messages.json +++ b/src/_locales/be/messages.json @@ -4,7 +4,7 @@ "description": "extension name." }, "extShortDesc": { - "message": "Нарэшце, эфектыўны блакіроўшчык. Не нагружае працэсар і памяць.", + "message": "Нарэшце, эфектыўны блакавальнік. Не нагружае працэсар і памяць.", "description": "this will be in the Chrome web store: must be 132 characters or less" }, "dashboardName": { diff --git a/src/_locales/eu/messages.json b/src/_locales/eu/messages.json index b87b777e7..5cf4565fb 100644 --- a/src/_locales/eu/messages.json +++ b/src/_locales/eu/messages.json @@ -540,7 +540,7 @@ "description": "Warning against copy-pasting filters from random sources" }, "1pEnableMyFiltersLabel": { - "message": "Enable my custom filters", + "message": "Aktibatu nire filtro pertsonalitsatuak", "description": "Label for the checkbox use to enable/disable 'My filters' list" }, "1pTrustMyFiltersLabel": {