0

i want start my js script if the page finish to loading.

Manifest:

"content_scripts": [ {
  "matches": [ "https://*.youtube.com/*", "http://*.youtube.com/*" ],
  "js": [
    "js/jquery-3.2.1.min.js",
    "js/youtube.js",
    "js/function.js"
  ],
  "css": [
    "css/youtube.css"
  ],
  "run_at": "document_end",
  "all_frames": false
  }
],

How I can start "js/youtube.js" and "js/function.js"?

The Youtube Page load but it load first my extension.

Sergii Rudenko
  • 2,603
  • 1
  • 22
  • 24
DavidsProTv
  • 121
  • 1
  • 2
  • 15

1 Answers1

1

Set value of "run_at" property in manifest file to "document_idle" (which is the default) and put your code in the content script file. Then the script will be run when the page is ready.

"run_at": "document_idle"

For more information, when document_idle is fires you can check this question.

Other option for you is to detect document load from background page and insert your content scripts after that. The best examples of this you can find here.

Sergii Rudenko
  • 2,603
  • 1
  • 22
  • 24