I have an website with an ajax form, and i want to get the inner text of a specific element inside that form.
The element doesn't exist when the page is first loaded.
I'm building a chrome extension to get that innertext value and print it to the console.
As i'm very new to JS, i just made the following code:
document.addEventListener('click', function () {
let text = document.querySelector("#\\39 8");
if (text !== null) {
console.log(text.innerText)
} else {
console.log('Nothing')
}
})
So i'm randomly clicking the webpage getting "Nothing"s, and expecting that when the element gets loaded i'll eventually get the innerText.
Problem is, as soon as i make the login into the webpage, i have nothing on the console. No "Nothing"s, no innerText..
My manifest includes all urls
{
"name":"Teste",
"version": "1.0",
"description": "Testing",
"manifest_version": 2,
"permissions":["storage"],
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["background.js"]
}]
}
Question is, what am i doing wrong? Shouldn't be expectable to have the innerText of that element being printed to the console?
EDIT:
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr"><head></head>
<frameset rows="82,*,0,0" framespacing="0" frameborder="0" id="FS"></frameset>
<frame name="Display" scrolling="no" piweb_src="action=../screen/display.html"></frame>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<body class="screenDisplay"></body>
<iframe name="MrcSessionA" id="MrcSessionA" frameborder="0" scrolling="no" style="display: inline;"></iframe>
#document
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<frameset id="Working" cols="*,800" border="2" bordercolor="#CCCCCC" framespacing="2" style="width: auto;"></frameset>
<frameset rows="70,*" framespacing="0" frameborder="0" style="width: auto;">
<frame name="EmulatorScreenMrcSessionA" id="EmulatorScreenMrcSessionA" scrolling="no" piweb_src="action=../applications/as400/emulator/help.html?IdentTab=MrcSessionA">
<html>
<body id="EmulatorBody">
<div id="DivBody" style="height: 488px;">
<form action="" name="PiTnForm" id="PiTnForm" method="post" onsubmit="return false;" autocomplete="off"></form>
<table id="emulatorTable" class="Ps80" style="border-collapse: separate;"></table>
<tbody id="AllPsRows">
<tr onclick="SelectOptionLine('')">
<td colspan = "17">
<input type="text" name="NewV" id="602" onfocus="GeneFocusOn(this);setCharShiftFocus({target:this});" onblur="GeneFocusOff(this)" onmouseup="GeneGetCPInputKey(this, event,true)" onkeyup="GenePsAutoTab(this,'17',event);setCharShiftFocus({target:this});" style="color:black; " maxlength="17" fa="U u " colour="G u " autotab="true" class="">
This is the tree of elements that i have. I'm trying to access the last row, the input textbox.