In my content scripts for my chrome extension, I dynamically load a external js file onto a html page once it is finished loading. This js file I load will define a variable called rfk
. I have a set Interval for when rfk
is defined, it will execute a script. However, even after succesfully loading the page, my content script will never find rfk
to be defined, even though I can check through the browser console and find that rfk
exists.
"content_scripts": [
{
"matches": ["*://www.att.com/*"],
"js": ["att.js"],
"run_at":"document_end"
}
]
This is my code snippet in my att.js file:
alert('hey!');
document.body.style.backgroundColor="red";
var url="//product.reflektion.com/rfk/js/11165-52846072/init.js?cv=test&q="+(new Date).getTime()
, o = document, s = o.createElement("script");
s.type="text/javascript";
s.src=url;
o.getElementsByTagName("head")[0].appendChild(s);
var cE = setInterval(function(){
rfk && (demo="instagram",rfk.P.fs.rw.extra_args={drsp:{_v:demo}},rfk.rebuild(),clearInterval(cE))
},100);