Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var pagno = 1; // Current page
- var req = new XMLHttpRequest();
- req.onreadystatechange=function() {
- if(req.readyState==4 && req.status==200)
- gotIt(req.responseText);
- }
- function request() { // Use an URL to help narrow even more the results instead of searching in the entire database
- var url = "http://e621.net/user/index.json?name="+escape(serch)+"&page="+pagno+"&order=name&level=-1";
- req.open("GET",url,true);
- req.send();
- }
- function gotIt(text) {
- if(text==="[]") { // No more pages
- // Notify that the specified user couldn't be found
- alert("User \""+serch+"\" does not exist");
- } else {
- var users = eval("("+text+")");
- var uname = "";
- var pos = 0;
- while(uname!=serch && pos<users.length) {
- uname = users[pos].name;
- pos++;
- }
- if(uname===serch)
- alert("\""+serch+"\" found at index "+pos+" on page "+pagno);
- else { // Advance to the next page and search again
- pagno++;
- request();
- }
- }
- }
- var serch = "e621"; // Username to look for (case sensitive)
- request();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement