Refs & Tips

Using TypeScripts

npm i chrome-types -D

Structure

(Không nhất thiết phải có folder ở ngoài, relate path định nghĩa trong manifest.json ← không cần / ở đầu path, eg. popup/hello.html)

source

source

How it works? (self understanding)

Giữa service-workercontent-script sẽ liên hệ với nhau qua messages. Cái content-script sẽ được gọi khi vừa install extension hoặc mở tab,… hoặc được trigger từ content-script.

Ngược lại cái service-worker có thể call lệnh trong content-script qua message (phải có chỉ định tab nào lúc gọi).

Các scripts được gọi phải nằm trong 1 list permissions (declare permissions and warn users) cụ thể + Các trang có thể gọi được thông qua các “patterns”.

Untitled

“permissions” (P) vs “host_permissions” (HP)