I'm trying to get my code to select the value assigned to a div box, and display it in an alert (more on this later). I was able to load the page, wait for the div to be assigned its value, and run the code no problem. However, when I had the code automatically execute when the tab was loaded by the extension, it fired before the div was assigned a value, and thus the command shell returned null (later, the alert box returned '---' which appears to be the default value of the div until it receives its value).
I'm looking to slow down the triggering of the content script before attempting to retrieve the div information, but have not been able to thus far.
Also, id like to be able to retrieve the value alertprice
to the js file for later processing too, but Ive no idea where to begin with that.
pedit: New to JavaScript, and have read tutorials, but they've helped me little. I appreciate the method of breaking down the code segments and explaining the functionality for anyone that has the time
function handleClick(state) {
tabs.open({
//url: a shopping/pricing website,
onLoad: extract
});
}
function extract(tab) {
tab.off('onLoad',extract);
tab.attach({
contentScript: "var buyPrice = document.getElementById('buy-price');"+
"var alertprice = buyPrice.innerHTML;"+
"alert(alertprice);"
});
}