When I click a button on a commecercial site, it pops open a window. That window will be the ip address, plus some string text. I can get that name, then I use the js code from my content script, referencing a js file. Within that file, I then use window.open to reference the popup window. Everything works except that last callback onUpdate(). This callback is a part of the popped up window, which is what I need to access, so I can use the save function.
js
function cfs_add(){
var test;
var text = "*.test.com"
test = String(window.origin)
test = test.substring(8,)
test = test.replace(/\:.*/,'');
test = test.split('.')
var existingWin = window.open('', test[0]+ "_" + test[1] + "_" + test[2] + "_" + test[3] + "_urlObjDlg");
console.log(test[0]+ "." + test[1] + "." + test[2] + "." + test[3])
existingWin.document.getElementsByClassName('button')[0].click()
existingWin.document.getElementsByTagName('input')[9].value = text
try{
existingWin.document.getElementsByClassName('button roundBtn swlEventSave')[0].click()
}
catch(err){
existingWin.document.getElementsByClassName('button roundBtn swlEventClose')[0].click()
}
existingWin.onUpdate();
}
cfs_add()
I have a chrome extension that works fine when I run it from within the Javascript Context below. I need to access a function that is part of another page/window. Since I know it works in the console, I assume I'll need to use something like "iframe.contentDocument || iframe.contentWindow.document". The function I need to run is part of the website out of my domain, so I"m accessing it via window.open and referencing the elements within. But the onclick will not work and that's because the call back it's referencing is part of another window... I think. I'm sure because it works fine if I run in the javascript Context as in the picture. If I change to another context like Top, it gives me the same error my Chrome extension gives me.
Where can I find information about this window element and how to manipulate it within my chrome extension?