In my Greasemonkey script I'm fetching some other web page and using the response in my code. However when I do this, it only gets the initial HTML content. If some of the content is async (which loads later) then I can't see that content in the response.
My researchs told me to use "waitForKeyElements", but it only work if the current url = the fetching page. It doesn't work when I fetch data from another web page.
If there is something I can do for my needs (not necessarily DOMParser), please tell me.
Here is my code:
// this script runs when I'm in google.com
GM_xmlhttpRequest({
url : "https://www.example.com",
method : "GET",
timeout: 10000,
onload : function(response) {
if (response.status == 200) {
const parser = new DOMParser();
const result = parser.parseFromString(response.responseText, "text/html").body;
let div = result.querySelector(".some-selector-here")
// returns null because this is async content
} else {
console.log(" Error: HTTP " +response.status+ " Error.");
}
},
});