Extensions

Extensions

  An extension is a zipped bundle of files—HTML, CSS, JavaScript, images, and anything else you need—that adds functionality to the Google Chrome browser. They can use all the APIs that the browser provides to web pages

Content Script

1、document.readystate

  Returns "loading" while the Document is loading, "interactive" once it is finished parsing but still loading sub-resources, and "complete" once it has loaded.

  参考:https://html.spec.whatwg.org/#dom-document-readystate

2、run_at. Optional.Controls when the files in js are injected. Can be "document_start", "document_end", or "document_idle". Defaults to "document_idle". 

  1)In the case of "document_start", the files are injected after any files from css, but before any other DOM is constructed or any other script is run. 

  2)In the case of "document_end", the files are injected immediately after the DOM is complete, but before subresources like images and frames have loaded. 

  3)In the case of "document_idle", the browser chooses a time to inject scripts between "document_end" and immediately after the window.onload event fires. The exact moment of injection depends on how complex the document is and how long it is taking to load, and is optimized for page load speed. 

示例:

  

 参考:https://developer.chrome.com/extensions/content_scripts

原文地址:https://www.cnblogs.com/tekkaman/p/5577794.html