I have a simple Chrome extension which injects content_script into pages found at certain URLs. I am trying to use the injected JS to call a function which is already defined within a frame of the original page (to piggyback on its functionality).
I have tried using window.frames['framename'].functionname('arg');
but that doesn't seem to work with the injection, but it would work if I were entering that directly into console. Similarly, attempting to call functionname()
directly doesn't seem to work. I know the javascript itself is injecting because once the page is loaded I have been able to set myscript.js to alert("test");
which works correctly, but if I attempt to call the functions I either get "not defined" or "not a function" errors in console. Looking at the console it seems that ['framename'] and ('arg') are being sanitised out of the javascript.
I have been searching for a while now to try and find a way to resolve this, but without any luck. Any ideas?
MANIFEST
{
// Required
"manifest_version": 2,
"name": "My Extension",
"version": "0.1",
"content_scripts": [
{
"matches": ["URL"],
"js": ["myscript.js"],
"run_at": "document_end",
"all_frames": true
}]
}
EDIT: Solved with Method 1 over here: Insert code into the page context using a content script
Sorry about the duplicate.