✅ – drilkmops – 23-31 Apr 12

bro ive been doing js for like 6 years and I have never done this before. I make a POST request and get something like the response below. How do I fire that JS..?
<!DOCTYPE html>
<html>
<body>
<script>
var redirectUrl = "https://www.example.com";
var anchor = encodeURIComponent(window.location.hash);
if (anchor.length > 0) {
redirectUrl = redirectUrl.replace("", anchor);
}
window.location = redirectUrl;
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<script>
var redirectUrl = "https://www.example.com";
var anchor = encodeURIComponent(window.location.hash);
if (anchor.length > 0) {
redirectUrl = redirectUrl.replace("", anchor);
}
window.location = redirectUrl;
</script>
</body>
</html>
D
drilkmops371d ago
Looks like I can use eval() or new Function and pass in the things in the script tag. Neat! So a solution would look something like this
const parser = new DOMParser();
const tempDoc = parser.parseFromString(htmlResponse, "text/html");
const functionToFire = new Function(doc.querySelector("script").textContent)
functionToFire()
const parser = new DOMParser();
const tempDoc = parser.parseFromString(htmlResponse, "text/html");
const functionToFire = new Function(doc.querySelector("script").textContent)
functionToFire()
UU
Unknown User370d ago