"Manifest의 모든 host pattern이 만지려고 permission 요청하는 인터넷의 한 평방마일. Lesson 3가 syntax, install prompt 비용, 가장 무서운 경고 최소로 가장 큰 reach 위해 ClipDeck design 하는 법."
URL match pattern syntax
Match pattern이 세 부분: scheme / host / path. ://와 /로 join:
<scheme>://<host>/<path>
예:
https://github.com/*— github.com root과 모든 path, HTTPS only.https://*.github.com/*— github.com AND 모든 subdomain (gist.github.com, api.github.com, ...).https://github.com/anthropics/*— anthropics org 아래 repository만.*://*/*— Chrome이 제한하는 거 (chrome://, 등) 외 모든 scheme, 모든 host, 모든 path. 몇 edge case 빼고<all_urls>와 동등.<all_urls>— explicit wildcard. HTTP / HTTPS / FTP / file: 매칭.
규칙:
- scheme 자리에는
http,https,file,ftp, 아니면*가 와. 평범한 extension 이라면chrome://와chrome-extension://은 무슨 수를 써도 안 걸려. - Host: literal, OR
*혼자 (모든 host), OR*.prefix (subdomain wildcard). Host 가운데 wildcard (foo*.example.com) 안 허용. - Path: literal 문자와
*wildcard. Path 필수. "모든 path" 면/*사용.
Install 경고 사다리
Chrome의 prompt가 host가 얼마나 넓은지에 따라 scale:
- 한 특정 host (
https://github.com/*) → "Read and change your data on github.com." - Subdomain wildcard (
https://*.github.com/*) → "Read and change your data on sites in the github.com domain." - 여러 특정 host (
https://github.com/*,https://gitlab.com/*) → "Read and change your data on github.com and gitlab.com." Chrome이 작은 한계까지 list, 다음 collapse. <all_urls>나*://*/*→ 시끄러운 "Read and change all your data on all websites."
"3 host" 와 "all websites" 사이 user 신뢰 drop이 가파름. 가능하면 host 좁게 cluster, 정말로 everywhere 동작해야 할 케이스에 <all_urls> 예약.
Chrome의 'Runtime Host Permission' twist
Chrome 70 쯤부터, user가 puzzle-piece menu 나 chrome://extensions 통해 installed extension의 site access 변경 가능: "On click," "On <specific site>," "On all sites." Manifest가 host_permissions: ["<all_urls>"] 선언해도, user가 "On click" 만으로 제한할 수 있어 — extension이 activeTab 처럼 동작하게 만듦.
여기서 따라 나오는 게 있어. manifest에 host 권한을 적어 뒀다고 해서 지금도 그렇다고 코드가 가정하면 안 돼. 중요한 자리라면 chrome.permissions.contains로 확인하든지, 아니면 host를 건드리는 기능 전부를 거절당해도 버티게 설계해. scripting 호출에서 'Cannot access contents of the page' 가 돌아오면 그걸 잡아서 이유를 설명해 주는 식으로.
Content-script match pattern
content script는 content_scripts 아래에 자기 matches 배열을 따로 갖고 있어. 문법은 같은데 host_permissions 와는 별개로 열리는 권한이야:
host_permissions가 programmatic inject (chrome.scripting), fetch, request 관찰할 권한 부여.content_scripts.matches가 매 page load 시 static, automatic injection 선언.
Chrome이 경고 목적으로 둘 union: host_permissions: ["<all_urls>"] OR content_scripts.matches: ["<all_urls>"]가 같은 무서운 경고 trigger. Host 좁히려면 두 field 함께 좁히기.
ClipDeck의 선택
ClipDeck v0.9가 content_scripts.matches: ["<all_urls>"] 가짐 — floating 버튼과 selection capture가 user 방문 모든 page에서 동작해야 해서. 경고 부드럽게 하는 두 방법:
- 항상-on content script 완전 drop. Toolbar click 이나 hotkey 시
activeTab+ programmaticchrome.scripting.executeScript사용. 비용: 매 page의 floating 버튼 없음, user가 부른 후만. 이득: install 경고 없음, 훨씬 친절. - content script는 그대로 두되 민감한 곳은 콕 집어 빼기. 닿는 범위는 넓게 유지하면서, 어떤 부류는 아예 안 건드린다고 user 한테 말해 주는 거야. 경고 문구는 그대로인데 신뢰를 주는 신호는 훨씬 세.
ClipDeck v1은 두 번째 경로 — floating 버튼이 discovery 이야기 일부라서. v2가 privacy-minded 무리 위해 activeTab-only mode로 전환하는 per-user toggle 추가할 수도.
<all_urls>가 어떤 prompt의 가장 시끄러운 줄 — 자격을 얻어. User가 runtime에 host downgrade 가능. 그것 위해 design.