开发 Chrome App / Extension 指引

开发 Chrome App / Extension 的指导

概述

https://www.cnblogs.com/liuxianan/p/chrome-plugin-develop.html

background 控制 -> popup -> options.html -> browserAction -> pageAction -> menucontext -> devtools -> omnibox -> ... Chrome App vs Chrome Extension

先要搞清楚 Chrome App 和 Chrome Extension 的区别:

生命周期不同 Extension 的 background 只要 persistent 设置为 true,那么这个 Extension 就会一直运行直到浏览器关闭 App 虽然也有 background,但和 Extension 的有很大不同。App 的 background 更像是一个入口文件(犹如C语言的main函数),详见 Chrome App Lifecycle App 可以比 Extension 调更多的 API,比如 fileSystem、mediaGalleries App JavaScript APIs Extension JavaScript APIs 权限不同,App 有更严格的权限策略

一般来说,Extension 和浏览器结合紧密,而 App 更像是一个独立的环境。

Extension Scripts vs Content scripts vs Inject scripts

* Extension Scripts — Full access to all permittedchrome.* APIs. This includes the background page, and all pages which have direct access to it viachrome.extension.getBackgroundPage(), such as thebrowser pop-ups. * Content scripts (via the manifest file orchrome.tabs.executeScript) — Partial access to some of the chrome APIs, full access to the page’s DOM (not to any of the window objects, including frames). Content scripts run in a scope between the extension and the page. The global window object of a Content script is distinct from the page/extension’s global namespace. * Injected scripts (via this method in a Content script) — Full access to all properties in the page.No access to any of the chrome.* APIs. Injected scripts behave as if they were included by the page itself, and are not connected to the extension in any way. See this post to learn more information on the various injection methods. --- https://medium.com/front-end-hacking/how-do-chrome-extensions-modify-webpages-using-content-scripts-9ae278e2bdf8 pass message file system content scripts background popup devtools

版权声明:

1、该文章(资料)来源于互联网公开信息,我方只是对该内容做点评,所分享的下载地址为原作者公开地址。
2、网站不提供资料下载,如需下载请到原作者页面进行下载。