Skip to content

Instantly share code, notes, and snippets.

@marinhero
Created March 2, 2018 01:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marinhero/0c9876b803e4f23b252e99bbaa478cba to your computer and use it in GitHub Desktop.
Save marinhero/0c9876b803e4f23b252e99bbaa478cba to your computer and use it in GitHub Desktop.
Traverse tokens recursively
//Only eligible in second account
var token_list = ['NPS-5cb686c1', 'NPS-8296bf77'];
var wootricSettings = {
account_token: ''
};
//wootric_survey_immediately = true;
//wootric_no_surveyed_cookie = true;
function isWootricVisible() {
return $('#wootric-modal').is(':visible');
}
function removeLastUsedToken() {
token_list.splice(0, 1);
}
function getNewToken() {
return token_list[0];
}
function eligible() {
token = getNewToken();
console.log('Checking for =>', token);
wootricSettings.account_token = token;
WootricSurvey.run(wootricSettings);
}
function traverseTokenList() {
eligible();
setTimeout(function(){
if (isWootricVisible() === true || token_list.length === 0) {
console.log('Exiting...');
return;
} else {
removeLastUsedToken();
traverseTokenList();
}
}, 8000);
}
$(document).ready(function(){
wootricSettings.email = 'marin+test@wootric.com';
traverseTokenList();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment