diff --git a/src/scriptlets/scriptlets-list.js b/src/scriptlets/scriptlets-list.js index ad044a95e..4fcb6e97f 100644 --- a/src/scriptlets/scriptlets-list.js +++ b/src/scriptlets/scriptlets-list.js @@ -70,7 +70,7 @@ export * from './json-prune-fetch-response'; export * from './no-protected-audience'; export * from './trusted-suppress-native-method'; export * from './json-prune-xhr-response'; -export * from './dispatch-event'; +export * from './trusted-dispatch-event'; // redirects as scriptlets // https://github.com/AdguardTeam/Scriptlets/issues/300 export * from './amazon-apstag'; diff --git a/src/scriptlets/dispatch-event.ts b/src/scriptlets/trusted-dispatch-event.ts similarity index 80% rename from src/scriptlets/dispatch-event.ts rename to src/scriptlets/trusted-dispatch-event.ts index 2c451ae83..f85952dd1 100644 --- a/src/scriptlets/dispatch-event.ts +++ b/src/scriptlets/trusted-dispatch-event.ts @@ -3,14 +3,14 @@ import { } from '../helpers/index'; /** - * @scriptlet dispatch-event + * @trustedScriptlet trusted-dispatch-event * * @description * Dispatches a custom event on a specified element. * * ### Syntax * ```text - * example.org#%#//scriptlet('dispatch-event', event [, element]) + * example.org#%#//scriptlet('trusted-dispatch-event', event [, element]) * ``` * * - `event` — required, name of the event to dispatch @@ -22,25 +22,25 @@ import { * 1. Dispatches a custom event "example-event" on the document. * * ```adblock - * example.org#%#//scriptlet('dispatch-event', 'example-event') + * example.org#%#//scriptlet('trusted-dispatch-event', 'example-event') * ``` * * 2. Dispatches a custom event "test-event" on the element with the class "test". * * ```adblock - * example.org#%#//scriptlet('dispatch-event', 'test-event', '.test') + * example.org#%#//scriptlet('trusted-dispatch-event', 'test-event', '.test') * ``` * * 3. Dispatches a custom event "window-event" on the window object. * * ```adblock - * example.org#%#//scriptlet('dispatch-event', 'window-event', 'window') + * example.org#%#//scriptlet('trusted-dispatch-event', 'window-event', 'window') * ``` * * @added unknown. */ -export function dispatchEvent( +export function trustedDispatchEvent( source: Source, event: string, element: string, @@ -94,10 +94,10 @@ export function dispatchEvent( EventTarget.prototype.addEventListener = new Proxy(EventTarget.prototype.addEventListener, handler); } -dispatchEvent.names = [ - 'dispatch-event', +trustedDispatchEvent.names = [ + 'trusted-dispatch-event', ]; -dispatchEvent.injections = [ +trustedDispatchEvent.injections = [ hit, ]; diff --git a/tests/scriptlets/dispatch-event.test.js b/tests/scriptlets/trusted-dispatch-event.test.js similarity index 98% rename from tests/scriptlets/dispatch-event.test.js rename to tests/scriptlets/trusted-dispatch-event.test.js index 409218f10..74aa29dc0 100644 --- a/tests/scriptlets/dispatch-event.test.js +++ b/tests/scriptlets/trusted-dispatch-event.test.js @@ -2,7 +2,7 @@ import { runScriptlet, clearGlobalProps } from '../helpers'; const { test, module } = QUnit; -const name = 'dispatch-event'; +const name = 'trusted-dispatch-event'; const createElem = () => { const div = document.createElement('div');