Initial commit
Diff
LICENSE.md | 22 ++++++++++++++-
README.md | 17 +++++++++++-
common.js | 31 ++++++++++++++++++++-
package.json | 20 +++++++++++++-
reaper.js | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
5 files changed, 184 insertions(+)
@@ -0,0 +1,22 @@
The MIT License
===============
Copyright (c) 2015 Jordan Doyle
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
\ No newline at end of file
@@ -0,0 +1,17 @@
# reaper
[![License](https://poser.pugx.org/laravel/framework/license.svg)](http://github.com/jordandoyle/reaper)
[League of Legends](http://leagueoflegends.com) mass summoner name checker. Supply a region and a list and the script will check the list for available summoner names. Common uses are finding quick variations of your name or finding rare (or "OG") names for selling. An API Key is required to do use this script, they are available for free from [Riot Games](https://developer.riotgames.com/), the API key is set in **reaper.js**.
This script includes a built-in rate limiter and a very basic web server for checking the status of the script remotely available on port **8090**.
The syntax of reaper is very simple:
node reaper.js [server (na/euw/lan/etc)] [username file] (output file)
For example:
node reaper.js euw username_list.txt output.txt
Will check the list username_list.txt for available summoner names on Europe West and output what it finds to output.txt
@@ -0,0 +1,31 @@
console.error = function(msg)
{
console.log("[".white + "!".red + "] ".white + msg.white);
};
console.info = function(msg)
{
console.log("[".white + "-".green + "] ".white + msg.white);
};
console.warn = function(msg)
{
console.log("[".white + "~".blue + "] ".white + msg.white);
};
exports.shuffle = function(array)
{
var currentIndex = array.length;
var temporaryValue;
var randomIndex;
while(currentIndex !== 0)
{
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
}
@@ -0,0 +1,20 @@
{
"name": "reaper",
"description": "League of Legends available name scraper",
"version": "1.0.2",
"author": "Jordan Doyle <jordan@doyle.wf>",
"main": "reaper.js",
"repository": {
"type": "git",
"url": "git://github.com/JordanDoyle/reaper.git"
},
"bugs": {
"url": "https://github.com/JordanDoyle/reaper/issues"
},
"dependencies": {
"chunk": "~0.0.2",
"colors": "~1.1.2",
"limiter": "~1.0.5"
},
"license": "MIT"
}
\ No newline at end of file
@@ -0,0 +1,94 @@
var common = require('./common');
var colors = require('colors');
var chunk = require('chunk');
var args = process.argv.slice(2);
var fs = require('fs');
var http = require('http');
var https = require("https");
if(args.length < 2 || args.length > 3)
{
console.error("Invalid syntax. Valid syntax: " + process.argv[0] + " " + process.argv[1] + " [server] [username input] (username output)");
}
var apiKey = "<api key here>";
var server = args[0];
var input = args[1];
var output = args[2];
var RateLimiter = require('limiter').RateLimiter;
var limiter = new RateLimiter(1, 'second');
var namesChecked = 0;
var namesFound = 0;
http.createServer(function(req, res)
{
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Names Checked: ' + namesChecked + '\nNames Found: ' + namesFound);
}).listen(8090);
var names = fs.readFileSync(input).toString().split('\n');
common.shuffle(names);
chunk(names, 40).forEach(function(chunked)
{
limiter.removeTokens(1, function(err, remainingRequests)
{
namesChecked += 40;
var users = chunked.join(',').replace(/[-]/g, ' ').replace(/[\r\n'.]/g, '');
https.get('https://' + server + '.api.pvp.net/api/lol/' + server + '/v1.4/summoner/by-name/' + users + '?api_key=' + apiKey, function(res)
{
if(res.statusCode === 404) {
chunked.forEach(function(name)
{
namesFound++;
console.info(name.replace(/[-]/g, ' ').replace(/[\r\n'.]/g, '') + " is available!");
if(output != undefined)
fs.appendFile(output, name + '\n');
});
} else if(res.statusCode === 200) {
var body = '';
res.setEncoding('utf8');
res.on('data', function(d) {
body += d;
});
res.on('end', function()
{
var obj = JSON.parse(body);
chunked.forEach(function(name)
{
name = name.replace(/[-]/g, ' ').replace(/[\r\n'.]/g, '').trim();
if(name.length < 3)
return;
if(obj[name] == undefined)
{
if(output != undefined)
fs.appendFile(output, name + '\r\n');
console.info(name + " is available!");
namesFound++;
}
});
});
}
});
});
});