要使用大多數 chrome.* API,你的擴充功能必須在 permissions 清單欄位中宣告其意圖。 擴充套件可以使用後續資料表中的權限字串宣告權限,或使用模式來匹配相似字串。 權限有助於限制你的擴充功能,以防它被惡意軟體入侵。 部分權限會在安裝擴充功能前或執行時顯示給使用者,以徵求同意;這些是授權警告。
如果某個 API 要求你在清單中宣告權限,請參考該 API 的文件來了解所需的權限。 例如, Storage API 頁面說明如何宣告權限 storage 。
以下是清單檔案中權限部分的範例:
"permissions": [
"tabs",
"bookmarks",
"storage"
],
"optional_permissions": [
"unlimitedStorage"
],
"host_permissions": [
"http://www.blogger.com/",
"http://*.google.com/"
],
下表列出目前可用於清單的權限字串及說明。
| 權限字串 | 詳細資料 |
|---|---|
activeTab |
請求擴充功能依規範獲得權限 activeTab 。 |
alarms |
讓你的擴充功能存取 chrome.alarms API。 |
background |
讓 Microsoft Edge 提早啟動、關閉較晚,讓擴充功能能有更長的壽命。 當任何已安裝的擴充功能擁有 background 權限時,Microsoft Edge 會在使用者登入電腦後立即執行,且在啟動 Microsoft Edge 之前。 此 background 權限也讓 Microsoft Edge 在最後一個視窗關閉後仍能持續運行,直到使用者明確退出 Microsoft Edge。 停用的擴充功能會被視為未安裝。 您應該使用服務人員的 background 權限;詳見 developer.chrome.com 關於 推廣服務人員 。 |
bookmarks |
讓你的擴充功能存取 chrome.bookmarks API。 |
browsingData |
讓你的擴充功能存取 chrome.browsingData API。 |
certificateProvider |
讓你的擴充功能存取 chrome.certificateProvider API。 |
clipboardRead |
若擴充使用 document.execCommand('paste')。 |
clipboardWrite |
表示擴展使用 document.execCommand('copy') 或 document.execCommand('cut')。 |
contentSettings |
讓你的擴充功能存取 chrome.contentSettings API。 |
contextMenus |
讓你的擴充功能存取 chrome.contextMenus API。 |
cookies |
讓你的擴充功能存取 chrome.cookies API。 |
debugger |
讓你的擴充功能存取 chrome.debugger API。 |
declarativeContent |
讓你的擴充功能存取 chrome.declarativeContent API。 |
declarativeNetRequest |
讓你的擴充功能存取 chrome.declarativeNetRequest API。 允許擴充功能在不需主機權限的情況下阻擋和升級請求,但需主機權限來重新導向請求或修改標頭。 |
declarativeNetRequestWithHostAccess |
讓你的擴充功能存取 chrome.declarativeNetRequest API。 必須對請求網址和發起者進行請求的主機權限。 |
declarativeNetRequestFeedback |
授權擴充套件存取 API 內 chrome.declarativeNetRequest 的事件與方法,並回傳與 API 匹配的宣告式規則資訊。 |
declarativeWebRequest |
讓你的擴充功能存取 chrome.declarativeWebRequest API。 |
desktopCapture |
讓你的擴充功能存取 chrome.desktopCapture API。 |
documentScan |
讓你的擴充功能存取 chrome.documentScan API。 |
downloads |
讓你的擴充功能存取 chrome.downloads API。 |
enterprise.deviceAttributes |
讓你的擴充功能存取 chrome.enterprise.deviceAttributes API。 |
enterprise.hardwarePlatform |
讓你的擴充功能存取 chrome.enterprise.hardwarePlatform API。 |
enterprise.networkingAttributes |
讓你的擴充功能存取 chrome.enterprise.networkingAttributes API。 |
enterprise.platformKeys |
讓你的擴充功能存取 chrome.enterprise.platformKeys API。 |
experimental |
如果擴充功能使用任何 chrome.experimental.* API,必須使用。 |
fileBrowserHandler |
讓你的擴充功能存取 chrome.fileBrowserHandler API。 |
fileSystemProvider |
讓你的擴充功能存取 chrome.fileSystemProvider API。 |
fontSettings |
讓你的擴充功能存取 chrome.fontSettings API。 |
geolocation |
允許擴充功能使用地理位置 API,且不會要求使用者取得許可。 |
history |
讓你的擴充功能存取 chrome.history API。 |
identity |
讓你的擴充功能存取 chrome.identity API。 |
idle |
讓你的擴充功能存取 chrome.idle API。 |
loginState |
讓你的擴充功能存取 chrome.loginState API。 |
management |
讓你的擴充功能存取 chrome.management API。 |
nativeMessaging |
讓你的擴充功能能存取原生訊息 API。 |
notifications |
讓你的擴充功能存取 chrome.notifications API。 |
pageCapture |
讓你的擴充功能存取 chrome.pageCapture API。 |
platformKeys |
讓你的擴充功能存取 chrome.platformKeys API。 |
power |
讓你的擴充功能存取 chrome.power API。 |
printerProvider |
讓你的擴充功能存取 chrome.printerProvider API。 |
printing |
讓你的擴充功能存取 chrome.printing API。 |
printingMetrics |
讓你的擴充功能存取 chrome.printingMetrics API。 |
privacy |
讓你的擴充功能存取 chrome.privacy API。 |
processes |
讓你的擴充功能存取 chrome.processes API。 |
proxy |
讓你的擴充功能存取 chrome.proxy API。 |
scripting |
讓你的擴充功能存取 chrome.scripting API。 |
search |
讓你的擴充功能存取 chrome.search API。 |
sessions |
讓你的擴充功能存取 chrome.sessions API。 |
sidePanel |
讓你的擴充功能存取 chrome.sidePanel API。 請參見 Microsoft Edge 側邊欄的「開發擴充功能」。 |
signedInDevices |
讓你的擴充功能存取 chrome.signedInDevices API。 |
storage |
讓你的擴充功能存取 chrome.storage API。 |
system.cpu |
讓你的擴充功能存取 chrome.system.cpu API。 |
system.display |
讓你的擴充功能存取 chrome.system.display API。 |
system.memory |
讓你的擴充功能存取 chrome.system.memory API。 |
system.storage |
讓你的擴充功能存取 chrome.system.storage API。 |
tabCapture |
讓你的擴充功能存取 chrome.tabCapture API。 |
tabGroups |
讓你的擴充功能存取 chrome.tabGroups API。 |
tabs |
讓你的擴充功能存取 Tab 物件的特權欄位,這些欄位可被多個 API 使用,包括 chrome.tabs 和 chrome.windows。 在許多情況下,你的擴充功能不需要宣告 tabs 權限即可使用這些 API。 |
topSites |
讓你的擴充功能存取 chrome.topSites API。 |
tts |
讓你的擴充功能存取 chrome.tts API。 |
ttsEngine |
讓你的擴充功能存取 chrome.ttsEngine API。 |
unlimitedStorage |
提供無限配額以儲存用戶端資料,例如資料庫與本地儲存檔案。 若未取得此許可,擴充功能僅能使用5 MB的本地儲存空間。 此權限僅適用於網頁SQL Database與應用程式快取 (見第 58985 期:本地儲存) 應適用無限儲存權限。 此權限目前無法用於像 . 這樣的通配子網域 http://*.contoso.com。 |
vpnProvider |
讓你的擴充功能存取 chrome.vpnProvider API。 |
wallpaper |
讓你的擴充功能存取 chrome.wallpaper API。 |
webNavigation |
讓你的擴充功能存取 chrome.webNavigation API。 |
webRequest |
讓你的擴充功能存取 chrome.webRequest API。 |
webRequestBlocking |
如果擴充套件使用 chrome.webRequest API 來阻擋請求,則必須如此。 |
注意事項
本頁部分內容基於 Google 創作與 分享 的作品,並依 據創用CC 姓名標示 4.0 國際授權條款進行修改。 原始頁面 可在此查閱。
本作品採用 創用CC 姓名標示4.0國際授權條款授權。