Does anyone have a full working example of accessing the chrome.permissions api from within an injected content script.
I've been trying to see if I can request cookie permission which has been configured to be an optional permission within an v2 manifest file but every time I try and access chrome.permissions it's not defined within the chrome.* namespace within my injected script.
Here is my current (v2) manifest file.
{
"manifest_version": 2,
"name": "Browser Extension",
"version": "5.0.0",
"description": "MV 2",
"optional_permissions": [
"cookies",
"<all_urls>"
],
"permissions": [
"alarms",
"storage",
"tabs",
"webNavigation"
],
"background": {
"scripts": [
"background.js"
],
"persistent": false
},
"browser_action": {
"default_title": "My Popup",
"default_popup": "popup.html",
"default_icon": {
"16": "icons/icon-16.png",
"19": "icons/icon-19.png",
"32": "icons/icon-32.png",
"48": "icons/icon-48.png",
"128": "icons/icon-128.png"
}
},
"content_scripts": [
{
"js": [
"serps.js"
],
"matches": [
"<all_urls>"
],
"include_globs": [
"*://www.google.*/*",
"*://www.bing.*/*"
],
"run_at": "document_idle",
"all_frames": false
},
{
"js": [
"retailer.js"
],
"matches": [
"<all_urls>"
],
"exclude_globs": [
"*://*.google.*/*",
"*://*.bing.*/*",
"*://*.youtube.*/*"
],
"run_at": "document_idle",
"all_frames": false
}
],
"web_accessible_resources": [],
"icons": {
"16": "icons/icon-16.png",
"48": "icons/icon-48.png",
"128": "icons/icon-128.png"
},
"minimum_chrome_version": "87"
}