Reputation: 97
window.open('https://starve.io/')
setTimeout(() => {
let c = prompt ("What is the password?")
let password = ['Ax', 'Buax','Oyl'];
function detectpassword(){
if (c == password) {
alert ('Thats the correct password');
} else {
alert ('Sorry thats wrong');
window.close()
}
}
detectpassword();
}, 10000);
Hello , what I'm trying to do that open that new window then execute the script on it but It just opens the new window and executes the script on the previous page not the one I just opened.
Upvotes: 0
Views: 81
Reputation: 460
I suspect you don't own the target site starve.io
. You will not be able to execute an arbitrary script there. This is a security measure. If this was not the case, anyone could embed starve.io
full-screen and read any data from it.
To execute an arbitrary script on anothre page you will need to create browser extension. Then you can use cross-tab communication to forward the password to your application.
Upvotes: 1