Last active
May 20, 2016 17:34
-
-
Save 064023/39dfeceeb8c424bddc5f 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
a = JSON.parse(document.documentElement.innerHTML.replace(/\n/g, "").replace(/^.*lastActiveTimes.*?\{/g, "{").replace(/\}.*/g, "}")); | |
idlist = {}; | |
myid = document.documentElement.innerHTML.replace(/\n/g, "").replace(/^.*\"USER_ID\":\"/g, "").replace(/\".*$/g, ""); | |
url = "//www.facebook.com/ajax/typeahead/search/facebar/bootstrap/?viewer=" + myid + "&__a=1"; | |
x = new XMLHttpRequest(); | |
x.onreadystatechange=function(){ | |
if (x.readyState==4 && x .status==200){ | |
srr=JSON.parse(x.responseText.substring(9)).payload.entries; | |
for(i=0;i<srr.length;i++){ | |
idlist[srr[i]["uid"]]=srr[i]["text"]; | |
} | |
d = []; | |
for(var id in a){ | |
time = a[id]; | |
console.log(id); | |
name = idlist[id]; | |
console.log(name); | |
t = new Date(time*1000); | |
year = t.getFullYear(); | |
month = t.getMonth()+1; | |
day = t.getDate(); | |
hour = t.getHours(); | |
min = t.getMinutes(); | |
sec = t.getSeconds(); | |
nowtime = Math.floor((new Date())/1000); | |
dsec = (nowtime-time)%60; | |
dmin = Math.floor((nowtime-time)/60)%60; | |
dhour = Math.floor((nowtime-time)/3600)%24; | |
dday = Math.floor((nowtime-time)/86400); | |
(dday==0 && dhour==0 && dmin==0 && dsec==0)?dsec="":dsec=dsec+"s"; | |
(dday==0 && dhour==0 && dmin==0)?dmin="":dmin=dmin+"m"; | |
(dday==0 && dhour==0)?dhour="":dhour=dhour+"h"; | |
dday==0?dday="":dday=dday+"d"; | |
//d.push([id, name, dday+"d "+dhour+"h "+dmin+"m "+dsec+"s "]); | |
d.push([id, name, year+"/"+month+"/"+day+" "+((hour<10)?("0"+hour):hour)+":"+((min<10)?("0"+min):min)+":"+((sec<10)?("0"+sec):sec), dday+" "+dhour+" "+dmin+" "+dsec]); | |
//console.log(key+","+year+","+month+","+day+","+hour+","+min+","+sec); | |
} | |
table = ""; | |
table += "<h2>lastActiveTimes</h2>"; | |
table += '<table border="1" style="border-collapse: collapse;">'; | |
for(i=0;i<d.length;i++){ | |
table+="<tr><td>"+d[i][0]+"</td><td>"+d[i][1]+'</td><td style="text-align: right;">'+d[i][2]+'</td><td style="text-align: right;">'+d[i][3]+"</td></tr>"; | |
} | |
table += "</table>"; | |
document.head.innerHTML = ""; | |
document.body.innerHTML = table; | |
} | |
} | |
x.open("GET",url,true); | |
x.send(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment