Skip to content

Instantly share code, notes, and snippets.

@DleanJeans
Last active December 31, 2018 07:45
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 DleanJeans/95958fd7a96f5d30ddb9277773bcd48b to your computer and use it in GitHub Desktop.
Save DleanJeans/95958fd7a96f5d30ddb9277773bcd48b to your computer and use it in GitHub Desktop.
s0urce.io Scripts & DB
window.seenWords = Object.assign({}, window.seenWords, {});
// The delay, in milliseconds
// 1000 milliseconds = 1 second
var theDelay = 750;
var duplicateCount = 0;
function canPwn() {
if(window.lastPwnTime == null) return true;
var now = new Date();
var timeDifference = now - window.lastPwnTime;
// Ensure we have waited enough time
return timeDifference > theDelay;
}
function didPwn() {
// We did a pwn, update the internal time
window.lastPwnTime = new Date();
}
function checkPwn(force) {
// Prevent pwning too fast
if(!canPwn()) return;
// ensure we have a store for seen values
window.seenWords = window.seenWords || {};
// grab the string number of this
var stringNumber = $('.tool-type-img').attr('src').replace('../client/img/word/','');
// Prevent incorrect spamming
var lastWordChoice = window.lastWordChoice;
if(lastWordChoice == stringNumber && !force)
duplicateCount++;
else
duplicateCount = 0;
if (duplicateCount >= 3)
return;
window.lastWordChoice = stringNumber;
// see if we've seen this before
var possibleWord = window.seenWords[stringNumber];
// Did we find the word?
if(possibleWord != null) {
console.log('Found word ' + possibleWord);
window.shouldntSubmit = true;
$('#tool-type-word').val(possibleWord);
$('#tool-type-form').submit();
// We did a pwn
didPwn()
setTimeout(function() {
$('#tool-type-word').val('');
window.shouldntSubmit = false;
}, 1);
}
}
$('#tool-type-word').on('keyup keypress keydown', function(e) {
if(window.shouldntSubmit) {
e.preventDefault();
return false;
}
if(e.which != 13) {
return;
}
// Grab what we typed
var currentEntry = $('#tool-type-word').val();
// Did we type anything?
if(currentEntry.length <= 0) {
// Check if we should pwn
checkPwn(true);
e.preventDefault();
return false;
}
// grab the string number of this
var stringNumber = $('.tool-type-img').attr('src').replace('../client/img/word/','');
// Store the answer
window.seenWords[stringNumber] = currentEntry;
// We did a pwn
didPwn();
});
function exportBotMemory() {
var theMemory = JSON.stringify(window.seenWords);
console.log('To load bot memory, paste the following into the console:');
console.log('window.seenWords = Object.assign({}, window.seenWords, ' + theMemory + ');');
}
// Set an interval to check if we can pwn
setInterval(checkPwn, 10);
// Tell the user how to use it
console.log('Start typing words, eventually the bot will take over. You can type "exportBotMemory()" into the console without quotes to save your bot\'s current state.');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment