Skip to content

Commit

Permalink
Change to trusted scriptlet
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamWr committed Apr 5, 2024
1 parent 9382072 commit 1f62260
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/scriptlets/scriptlets-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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,
];
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 1f62260

Please sign in to comment.