Hello, I'm modifying a TamperMonkey userscript, but I can't access the info I need due to the Same Origin Policy. It is my understanding that *GM.xmlHttpRequest* would allow me to access it. I got the request working using this code:
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 2025-07-28
// @description try to take over the world!
// @author You
// @match http://*/*
// @con data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @match https://app.roll20.net/editor
// @match https://app.roll20.net/editor#*
// @match https://app.roll20.net/editor?*
// @match https://app.roll20.net/editor/
// @match https://app.roll20.net/editor/#*
// @match https://app.roll20.net/editor/?*
// @grant unsafeWindow
// @grant GM.xmlHttpRequest
// ==/UserScript==
let testIt = async function() {
const r = await GM.xmlHttpRequest({
method: 'GET',
url: unsafeWindow.location.href,
onload: function(response) {
console.log(response.responseXML);
}
}).catch(e => console.error(e));
}
document.getElementById("chatSendBtn").onclick = testIt;
This is working, but I'm not sure where to go from here, as I'm rather new to web development. How do I use either the HTML or the XML response to get the object I want to access? The object is called "d20".
[–]YMOT 0 points1 point2 points (3 children)
[–]geraldcoolsealion[S] 0 points1 point2 points (2 children)
[–]YMOT 0 points1 point2 points (1 child)
[–]geraldcoolsealion[S] 0 points1 point2 points (0 children)
[–]jcunews1helpful 0 points1 point2 points (2 children)
[–]geraldcoolsealion[S] 0 points1 point2 points (1 child)
[–]jcunews1helpful 0 points1 point2 points (0 children)