Scriptlets icon indicating copy to clipboard operation
Scriptlets copied to clipboard

Add scriptlet to trigger event - dispatchEvent()

Open AdamWr opened this issue 2 years ago • 0 comments

It could be useful in this case - https://github.com/AdguardTeam/AdguardFilters/issues/166126 Instead of allowing cookie notice and closing it, we could use dispatchEvent() to load video player.

Something like:

function dispatchCustomEvent(event, element) {
  if (!event) {
    return;
  }
  const ev = new CustomEvent(event);
  const el = element ? document.querySelector(element) : document;
  if (el) {
   el.dispatchEvent(ev);
  }
}

and then:

dispatchCustomEvent('consentGranted')

AdamWr avatar Nov 14 '23 07:11 AdamWr