Skip to content

Instantly share code, notes, and snippets.

@AndrewMast
Last active August 3, 2020 05:18
Show Gist options
  • Save AndrewMast/f06c8db5a13905b142df0ebe3dcf9d6c to your computer and use it in GitHub Desktop.
Save AndrewMast/f06c8db5a13905b142df0ebe3dcf9d6c to your computer and use it in GitHub Desktop.
(async function () {
let interval = null;
let counter = 0;
const fetch = async function(url) {
try {
return await $.ajax(url, {dataType: "json"});
} catch (error) {
console.log('Error:', error);
}
}
const sendRequest = async function() {
let code = await fetch('https://www.mrriddle.com/qrjustgettingstarted/api/get-next-code');
if (code.response_code === true) {
let message = await fetch('https://www.mrriddle.com/qrjustgettingstarted/content/' + code.data.location);
if (!message.html.includes('WRONG WAY')) {
console.log('Success:', {code, message});
console.log('https://www.mrriddle.com/qrjustgettingstarted/' + code.data.location);
clearInterval(interval);
} else {
console.log('Failed:', counter++);
}
}
};
interval = setInterval(sendRequest, 500);
})();
@thesharkjonas
Copy link

Nice! I was going to do this myself using the same approach but I like this.

@thesharkjonas
Copy link

thankyou for the help

@lmancini1
Copy link

didnt work

@lotofd
Copy link

lotofd commented Aug 1, 2020

Omg it worked like a charm tysm lol

Copy link

ghost commented Aug 2, 2020

https://www.mrriddle.com/qrjustgettingstarted should be https://www.mrriddle.com/qrjustgettingstarted/

The website doesn't render properly without the trailing '/'

@AndrewMast
Copy link
Author

AndrewMast commented Aug 3, 2020

@Nicolas-Connor Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment