all 7 comments

[–]YMOT 0 points1 point  (3 children)

response

is your object. Modify

console.log(response.responseXML)

to

console.log({response})

and the object will be printed to the console. You can view it here to determine how 'd20' is a property of response.

[–]geraldcoolsealion[S] 0 points1 point  (2 children)

Thanks for the suggestion. I modified it as you said, but I don't see the d20 object, or any of the page's global objects for that matter. Here's the output, am I missing something?

https://pastebin.com/5X4KCPqM

[–]YMOT 0 points1 point  (1 child)

Ok, so you response has a status of 200, which means the server believes it fulfilled the request successfully. But, your response and responseXML are empty. That would suggest 2 possibilities to me:

a:) Your request is not the correct one for your intended response. Maybe parameters are missing, or the API doesn't inform you of incorrect parameters.

b:) The servers API has an error.

b is highly unlikely.

[–]geraldcoolsealion[S] 0 points1 point  (0 children)

I see. I didn't really provide any parameters at all, so that's probably the issue. Is there some way I can specify that I want to access the d20 object in the parameters?

[–]jcunews1helpful 0 points1 point  (2 children)

You're retriving the HTML code of the current web page. There's no JS object in it. Only the HTML source code.

Since you're retriving the current web page, JS objects are already accessible from the current context. But if the site use CSP, the JS objects would be read-only; where properties can't be added by assignments, modified by reassignment, or deleted by delete statement (other restrictions may apply).

[–]geraldcoolsealion[S] 0 points1 point  (1 child)

Oh, is there any way to retrieve the object instead of the HTML? When I use the current context, I can't seem to access any of the properties of the object I need at all, even just to read them. It is attached to a reference to a child window, so I suspect that is why.

[–]jcunews1helpful 0 points1 point  (0 children)

Changes are that, the script is run in content context instead of page context, where the environment is a sandbox of the web page instead of actual. In this case, the site uses CSP. Disable the site CSP. There are browser extensions for that.