I'm trying to make a chrome extension that reloads an iframe of a site in the background every x seconds. This site requires login but as long as a user is active on the site, it doesn't log you out. I'm trying to get some information from the HTML of the site. However, when I load the iframe in the background script with the url, it redirects the iframe to a different url. I'm guessing it is because the iframe in the background doesn't work like opening the url in the actual chrome browser(When I loaded an iframe with the same url in a content script, the exact url loaded perfectly). Does anyone have any suggestions on how I could load a background iframe with a url that automatically redirects it(which I don't want)?
manifest.json
{
"name":"Actual IC Notifications",
"version": "1.2",
"manifest_version":2,
"description":"Short description",
"permissions": ["<all_urls>"],
"browser_action":{
"default_icon":"bell.png",
"default_popup":"popup.html"
},
"background":{
"all_frames": true,
"scripts":["background.js"]
}
}
background.js
console.log("background is running");
window.onload = function(){
var frame = document.createElement('iframe');
frame.src = 'https://philasd.infinitecampus.org/campus/nav-wrapper/student/portal/student/today';
document.body.appendChild(frame);
window.addEventListener('message',function(e){
console.log("message received: " + JSON.stringify(e.data));
});
console.log('posting message to iframe');
frame.addEventListener('load',function(){
frame.contentWindow.postMessage("TestMessage","*");
});
};
Background script console errors
Console output: