I'm trying to write a greasemonkey script that will automatically perform the Steam store age check before allowing you to view mature game content.
My problem is that after the form is submitted, the website automatically redirects to a new page, and the rest of the greasemonkey script doesn't get a chance to execute:
// ==UserScript==
// @name agecheck
// @include http://store.steampowered.com/agecheck/*
// @version 1.17
// @modified 11/23/2012
// @grant GM_xmlhttpRequest
// ==/UserScript==
//Mini script for doing steam age checks automatically (used when scraping steam sites)
if (/agecheck/i.test (location.pathname) ) {
var ageForm = document.querySelector ("#agegate_box form");
ageForm.querySelector ("[name='ageDay']").value = 18;
ageForm.querySelector ("[name='ageMonth']").value = 'August';
ageForm.querySelector ("[name='ageYear']").value = 1987;
ageForm.submit();
setTimeout( function(){ window.close(); }, 10000); //Never gets to run
}
To verify the code is valid, if I simply comment out the ageForm.submit();
statement, the tab closes after 10 seconds as desired.
How can I get the window to close after submitting the form?