Chrome插件开发学习笔记(一)

本文介绍了 Chrome 浏览器插件的开发流程和技术要点,包括插件的基本组成、主要文件类型及其作用,如 manifest.json 文件的作用及内容脚本的工作原理等。此外还探讨了页面间的通信方式以及如何处理隐身模式下的数据。

AI 驱动代码审查实战

Claude code-review 插件深度解析,把 AI 智能审查接进 CI/CD 流水线

Chrome Plugin Guide

Summary

-          An extension is a zipped bundle of files – HTML, CSS, JS, images, and anything else you need.

-          Extensions are essentially web pages, and they can use all the APIs that the browser provides

-          Many extensions add UI to Chrome in the form of browser actions or page actions.

-          Extensions can also interact programmatically with browser such as bookmarks and tabs.

-          To interact with web pages or servers, extensions can use content scripts or cross-origin XMLHttpRequests.

1.       Choose a browser action when the extension is relevant to most pages.

2.       Choose a page action when the extension’s icon should appear or disappear

-          Each extensions has the following files:

1.       A manifest file

2.       One or more HTML files

3.       [optional] One or more JavaScript files

4.       [optional] Any other your extensions need, like images files

-          When distribute extension, the contents of the folder are packaged into a special ZIP file that has a .crx suffix.

-          You can refer to the file in your extension by relative URL. Every file in an extension is also accessible by an absolute URL like this:  chrome-extension://<extensionID>/<pathToFile>

-          extensionID is a unique identifier that the extension system generates for each extension.

 

Manifest file

-          The manifest file, called manifest.json, gives information about the extension, such as the most important files and the capabilities that the extension might use.

 

Content Scripts

-          A content script is some JavaScript that executes in the contect of a page that’s been loaded into the browser. Think of a content script as part of that loaded page, not as part of the extension

-          Content scripts can read details of the web pages the browser visits, and they can make change to the page.(modify the DOM for the displayed web page, but cann’t modify the background page)

-          A content script can exchange messages with its parent extension.

Chrome Plugin-1

Communicaiton between pages

-          The HTML pages with in an extension often need to communicate. Because all of an extension’s pages execute in same process on the same thread, the pages can make direct function calls to each other.

-          Incognito mode promises that the window will leave no tracks. When dealing with data from incognito windows, do your best to honor this promise. (check tab.incognito property)

 

 

AI 驱动代码审查实战

Claude code-review 插件深度解析,把 AI 智能审查接进 CI/CD 流水线

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值