In order for my extension to work correctly I am injecting my Javascript into the page itself via my extension.
function injectScript(file, node) {
var th = document.getElementsByTagName(node)[0];
var s = document.createElement('script');
s.setAttribute('type', 'text/javascript');
s.setAttribute('src', file);
th.appendChild(s);
}
injectScript( chrome.extension.getURL('script.js'), 'body');
The problem with this approach is I am doing all of my manipulations in the injected script, rather than the main js file. This means I don't have access to the Chrome API. I want to use chrome.storage
however I can't now.
Is there a way to get the data from the variable on the website and pass it back to my extension without having to work in the page itself like this?
Edit, attempting to use window.variable (in chrome console):
In top frame:
window.delimitedMeetingInfo
["1|FOOD*2010*DE|2015/01/05|2015/04/17|LEC|Days TBA|Times TBA|Room TBA", "2|CIS*2500*0104|2015/01/05|2015/04/17|LEC|Mon, Wed, Fri |02:30PM - 03:20PM|ROZH, Room 101", "2|CIS*2500*0104|2015/01/05|2015/04/17|LAB|Wed |10:30AM - 12:20PM|THRN, Room 2418", "3|CIS*2170*0101|2015/01/05|2015/04/17|LEC|Tues, Thur |08:30AM - 09:50AM|CRSC, Room 116", "3|CIS*2170*0101|2015/01/05|2015/04/17|LAB|Tues |02:30PM - 04:20PM|MCKN, Room 233", "4|CIS*1910*0105|2015/01/05|2015/04/17|LEC|Tues, Thur |11:30AM - 12:50PM|MACN, Room 105", "4|CIS*1910*0105|2015/01/05|2015/04/17|LAB|Fri |12:30PM - 02:20PM|MCKN, Room 229", "5|CIS*2250*0103|2015/01/05|2015/04/17|LEC|Mon, Wed, Fri |09:30AM - 10:20AM|JTP, Room 214", "5|CIS*2250*0103|2015/01/05|2015/04/17|LAB|Wed |12:30PM - 02:20PM|REYN, Room 114"]
In extension frame:
window.delimitedMeetingInfo
undefined