Skip to content

Instantly share code, notes, and snippets.

@lazurey lazurey/xumin.js
Last active Jan 30, 2018

Embed
What would you like to do?
丑陋的续命脚本
// ==UserScript==
// @name iXumin
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Long live the elder!
// @author Sause
// @match http://ixumin.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var successCount = 0;
var failedCount = 0;
let xuminAgain;
let scoreboardEle;
const createOneRequest = () => {
const xumin = new XMLHttpRequest();
xumin.open("POST", 'https://api.ixumin.com/xu_web.php', true);
xumin.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
const rnd = Math.floor(Math.random() * 100);
xumin.send(`name=mahoushoujyo${rnd}&rnd=${rnd}`);
console.log('send: ', rnd);
xumin.onload = () => {
if (xumin.readyState === xumin.DONE) {
if (xumin.status === 200) {
const res = JSON.parse(xumin.response);
if (res.status === "success") {
successCount++;
scoreboardEle.innerHTML = "<h3>已续命 " + successCount + "s</h3>";
} else {
failedCount++;
}
} else {
failedCount++;
}
}
};
};
var startBtn = document.createElement("button");
startBtn.innerText = "Start +1s";
startBtn.className = "btn";
startBtn.style.cssText = "z-index: 9999; position: fixed; top: 10px; left: 10px;";
startBtn.onclick = () => {
console.log('Start to +1s every 1s');
scoreboardEle = document.getElementById("scoreboard");
xuminAgain = setInterval(createOneRequest, 1000);
};
document.body.appendChild(startBtn);
var stopBtn = document.createElement("button");
stopBtn.innerText = "Stop";
stopBtn.className = "btn";
stopBtn.style.cssText = "z-index: 9999; position: fixed; top: 10px; left: 140px;";
stopBtn.onclick = () => {
clearInterval(xuminAgain);
console.log('Stop to +1s every 1s');
};
document.body.appendChild(stopBtn);
var scoreboard = document.createElement("div");
scoreboard.id = "scoreboard";
scoreboard.innerHTML = "<h3>已续命 0s</h3>";
scoreboard.style.cssText = "z-index:9999;position:fixed;top:80px;left:10px;width: 200px; text-align: center;";
document.body.appendChild(scoreboard);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.