0

On website I have .on('click') and on my content.js I have addEventListener('click') both for same button.

If I click on the element, script from website is execute before my content.js script, on my manifest I have "run_at": "document_end", I can't set it to document_start because have to wait for DOM to be ready.

Is it possible? Or any tips to accomplish this task?

S. Wasta
  • 599
  • 9
  • 35
  • As explained in the duplicate target questions, using `document_start` makes your content script run prior to page scripts. It's *the* way to do that. When using `document_start`, what actions you take and when you take them with respect to the DOM being ready is something you have to program yourself in your content script. – Makyen Jul 03 '21 at 14:39
  • I changed to run_at and set document_start, and on content script wait for DOM to be ready. But content script is execute after website listener (click event). I wait for DOM ready on both scripts... – S. Wasta Jul 05 '21 at 19:05
  • Without a [mcve], including a manifest.json and your JavaScript code, it's not possible to provide you with any detailed response. If you're waiting for the DOM to be ready, then it's likely that the code which you delay to run after the DOM is ready will run after some code from the page is run. What timing actually happens will be in the details. However, content scripts which are defined as a manifest.json content script which are run at `document_start` will typically be executed prior to the existence of the `` or `` and prior to any page JavaScript running. – Makyen Jul 05 '21 at 19:13

0 Answers0