I have a website https://example.com where users can adjust their site preferences, including enabling night mode. To enhance the user experience, I developed a Chrome extension for https://example.com that transforms Chrome's new tab with a custom newtab.html file. My goal is to synchronize the new tab appearance with the user's chosen preferences stored in a cookie on https://example.com, such as activating night mode through CSS adjustments.
In my manifest file, I specified the necessary permissions:
"permissions": [ "*://*/*", "http://*/*", "https://*/*", "https://example.com", "tabs", "cookies", "contextMenus", "webRequest", "webRequestBlocking", "webNavigation", "activeTab", "storage", "alarms" ]
Within newtab.html, I included the following script:
<script type="text/javascript" src="js/newtab.js"></script>
The content of newtab.js consists of the code snippet below:
var cookie = chrome.cookies.get({url: "example.com", name: "preferences"});
console.log(cookie);
However, an error message appears in the console:
Uncaught TypeError: Error in invocation of cookies.get(object details, function callback): No matching signature.
I am seeking assistance in understanding what I may be doing incorrectly. How can I successfully retrieve the cookie from example.com within the newtab.html page to dynamically modify its CSS?
Thank you for your anticipated support and guidance in resolving this issue.