Skip to content

Instantly share code, notes, and snippets.

@advancedxy
Created May 5, 2014 02:29
Show Gist options
  • Save advancedxy/a6bf35960ab417bbb877 to your computer and use it in GitHub Desktop.
Save advancedxy/a6bf35960ab417bbb877 to your computer and use it in GitHub Desktop.
喜刷刷
box = $("div.m-chatform .edit textarea")
btn = $("div.m-chatform .btn")
var txt = ''
lines = []
function init() {
var xhr = new XMLHttpRequest()
xhr.open("GET", "http://10.240.138.100/tmp/tang.txt", true)
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
txt = xhr.responseText
lines = txt.split("\n")
}
};
// get a very long string in `txt`
xhr.send();
}
function randomSend(lines) {
line = lines[getRandomInt(0, lines.length)]
box.value = line
btn.click()
}
function getRandomInt(min, max) {
return Math.floor(Math.random()*(max-min)) + min
}
function sleep(millis, callback) {
setTimeout(function()
{ callback(lines); }
, millis);
}
init()
setInterval(function () { sleep(getRandomInt(20,30)*1000, randomSend) }, 60*1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment