I'm currently trying to select all spans that start with MTG_INSTR and follow by a number (MTG_INSTR1, MTG_INSTR2, etc). I've tried jquery and editing the text to test it using
(function() {
"use strict";
window.onload = function() {
gatherNames();
};
function gatherNames()
{
$("span[id^='MTG_INSTR$']").val("TEST");
setTimeout(gatherNames, 5000);
}
})();
but that didn't work as nothing happened. I also tried using querySelectorAll
var elements = document.querySelectorAll("[id^=MTG_INSTR$]");
for (var i = 0; i < elements.length; i++)
{
var text = elements[i].innerHTML;
alert(text);
}
that also didn't work. I'm trying to do this for my school's class search page and gather all the teacher's names for a chrome extension. This is my first attempt at a chrome extension and I'm using this piece on the content_script.js file if it matters and an example of the HTML for the corresponding span/parent div is
<div id="win0divMTG_INSTR$2">
<span class="PSLONGEDITBOX" id="MTG_INSTR$2">EXAMPLE NAME</span>
</div>
Also, this is part of my manifest.json that includes the jquery.js I downloaded and placed in the same folder as the other files.
"background": {
"scripts": [
"jquery.js",
"background.js"]
"persistent": false
},
"content_scripts": [
{
"matches":[
"css": ["content_script.css"],
"js": ["jquery.js", "content_script.js"]
}
]