I am using manifest v3 and trying to read window variable of the host
let tabs = await chrome.tabs.query({ currentWindow: true, active: true });
if (tabs.length > 0) {
//let url = tabs[0].url;
//console.table(new URL(url as string));
const tabId = tabs[0].id;
chrome.scripting.executeScript(
{
target: { tabId: tabId as number },
func: () => {
console.log("test"); //printing test
console.log(window); //printing window object
console.log(window._spPageContextInfo); // undefined
//window._spPageContextInfo.toString();
}
},
(result) => {
console.log(result[0].result);
}
);
}
I am able to access all default window variables but the custom variables generated by the SharePoint website. Basically I am trying to read sppagecontext Am I missing something?
here are permissions set in manifest.json
"permissions": [
"tabs",
"activeTab",
"cookies",
"scripting"
],
"host_permissions": [
"http://*.sharepoint.com/"
],
"content_security_policy": {
"script-src": "self unsafe-inline unsafe-eval",
"object-src": "self"
}