Skip to content

Instantly share code, notes, and snippets.

@icholy
Last active August 29, 2015 14:09
Show Gist options
  • Save icholy/c45b906f9331c8c4b78b to your computer and use it in GitHub Desktop.
Save icholy/c45b906f9331c8c4b78b to your computer and use it in GitHub Desktop.
/**
* 1. Go to this page: https://my.playstation.com/logged-in/trophies/public-trophies/ (using google chrome)
* 2. Right click on the page and select "inspect element"
* 3. Go to the "console" tab.
* 4. Change the names below with the ones you want to test
* 5. Copy/Paste the following script in the console and hit "enter".
*/
(function () {
// PASTE YOUR NAMES HERE
// http://www.namegenerator.biz/screen-name-generator.php
var names = (function () { /*
TheChangeableGamer
TheJaggedMike
TheMomentousMike
TheElfinMike
TheUnevenMike
TheSleepyMike
*/});
var extractNames = function (fn) {
return fn
.toString()
.split("\n")
.slice(1, -1)
.map(function (line) {
return line.trim();
})
.filter(function (line) {
return line.length > 0;
});
};
var isAvailable = function (name, callback) {
var url = "https://my.playstation.com/playstation/psn/profile/public/userData?onlineId=";
$.getJSON(url + name).then(function (data) {
callback(null, typeof data.handle === "undefined");
}, function (error) {
callback(error, null);
});
};
var availabelNames = [],
pending = 0;
extractNames(names).forEach(function (name) {
pending++;
isAvailable(name, function (error, available) {
if (error === null) {
console.log(name, available ? ":)" : ":(");
if (available) {
availabelNames.push(name);
}
} else {
console.log(name, error);
}
if (--pending === 0) {
console.log(
"\n\n" +
availabelNames.length.toString() +
" name(s) available:\n\n"
);
availabelNames.forEach(function (name) {
console.log("\t" + name);
});
}
});
});
}).call(null);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment