Created
October 18, 2017 17:22
-
-
Save bob1171/33850a90c348698420418464715813ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Scratch Messages Finder | |
// @namespace scratch.mit.edu/users/bob1171 | |
// @version 1.1 | |
// @description Displays someone's message count | |
// @author @bob1171 | |
// @match https://scratch.mit.edu/users/* | |
// @grant none | |
// ==/UserScript== | |
var Url = window.location.href; | |
var user = Url.split('/')[4]; | |
var number = getMessageCount(user); | |
if (number !=='NotFound","message":""') | |
{ | |
alert(number); | |
} | |
else | |
{ | |
alert('This user does not exist. You can make this account!'); | |
} | |
function getMessageCount(user) | |
{ | |
xmlHttp = new XMLHttpRequest(); | |
xmlHttp.open( | |
"GET", | |
"https://api.scratch.mit.edu/users/" + user + "/messages/count", false); | |
xmlHttp.send(null); | |
var raw = xmlHttp.responseText; | |
var number = raw.substring(9, raw.length - 1); | |
return number; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment