Kachang404

Script Auto Reaction

Aug 30th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var robot={
  2.   "email":"zuck@gmail.com",
  3.   "user_password":"kasih tau gak ya",
  4.   "type":{
  5.     "like":false,
  6.     "love":false,
  7.     "haha":false,
  8.     "wow":false,
  9.     "sad":false,
  10.     "angry":false,
  11.     "random":true
  12.   }
  13. };
  14.  
  15. var aing={
  16.   sp:PropertiesService.getScriptProperties(),
  17.   acak:function(a){return a[Math.floor(Math.random()*a.length)]},
  18.   aduk:function(a){var b=a.length,c,d;while(0!==b){d=Math.floor(Math.random()*b);b-=1;c=a[b];a[b]=a[d];a[d]=c}return a},
  19.   getApi:function(huh){var a=UrlFetchApp.fetch(huh,{muteHttpExceptions:true,method:"get",followRedirects:false,headers:{"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) Gecko/20100101 Firefox/54.0"}}),b=JSON.parse(a.getContentText());return b},
  20.   setApi:function(huh,pl){var a=UrlFetchApp.fetch(huh,{muteHttpExceptions:true,method:"post",payload:pl,followRedirects:false,headers:{"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) Gecko/20100101 Firefox/54.0"}}),b=JSON.parse(a.getContentText());return b},
  21.   md5:function(a,b){var c="",d=Utilities.computeDigest(Utilities.DigestAlgorithm.MD5,a,Utilities.Charset.UTF_8);if(!b){for(i=0;i<d.length;i++){var e=d[i];if(e<0){e+=256};if(e.toString(16).length==1){c+="0"};c+=e.toString(16)}}else{for(j=0;j<16;j+=8){e=(d[j]+d[j+1]+d[j+2]+d[j+3])^(d[j+4]+d[j+5]+d[j+6]+d[j+7]);if(e<0){e+=1024};if(e.toString(36).length==1){c+="0"};c+=e.toString(36)}};return c.toLowerCase()},
  22.   buildUrl:function(a,b){var c="";for(var d in b){var e=b[d];c+=encodeURIComponent(d)+"="+encodeURIComponent(e)+"&"}if(c.length>0){c=c.substring(0,c.length-1);a=a+"?"+c}return a},
  23.  
  24.   ambilToket:function(){
  25.     var a={
  26.       "api_key":"3e7c78e35a76a9299309885393b02d97",
  27.       "email":robot.email,
  28.       "format":"JSON",
  29.       "locale":"en_us",
  30.       "method":"auth.login",
  31.       "password":robot.user_password,
  32.       "v":"1.0"
  33.     };
  34.     var b="";for(var x in a){b+=x+"="+a[x]}
  35.     b+="c1e620fa708a1d5696fb991c1bde5662";b=aing.md5(b);
  36.     if(b){Logger.log("Getting access_token...");var c=aing.buildUrl("https://b-api.facebook.com/restserver.php",a);c+="&sig="+b}
  37.     var d=aing.getApi(c);
  38.     if(d&&d.access_token){Logger.log("Get access_token success");aing.sp.setProperty("toket",d.access_token)}else{Logger.log(d.error_msg);aing.sp.setProperty("toket","")}
  39.   }
  40. };
  41.  
  42. function reaction(){
  43.   var toket=aing.sp.getProperty("toket");
  44.   if(toket!=null&&toket!==""){
  45.     var a=aing.getApi("https://b-graph.facebook.com/me?access_token="+toket);
  46.     if(a&&a.id){
  47.       var b=aing.getApi("https://b-graph.facebook.com/me/home?access_token="+toket+"&fields=id&limit=5");
  48.       if(b&&b.data&&b.data.length!=0){
  49.         for(x in b.data){
  50.           var c=aing.getApi("https://b-graph.facebook.com/"+b.data[x].id+"/reactions?access_token="+toket+"&limit=100"),d="y";
  51.           if(c&&c.data&&c.data.length!=0){for(z in c.data){if(c.data[z].id==a.id){d="n";break}}}
  52.           if(robot.type.like){aing.type="LIKE"}else if(robot.type.love){aing.type="LOVE"}else if(robot.type.haha){aing.type="HAHA"}else if(robot.type.wow){aing.type="WOW"}else if(robot.type.sad){aing.type="SAD"}else if(robot.type.angry){aing.type="ANGRY"}else if(robot.type.random){var tp=["LIKE","LOVE","WOW","HAHA","SAD","ANGRY"];aing.type=aing.acak(tp)}
  53.           if(d=="y"){
  54.             var e=aing.setApi("https://b-graph.facebook.com/"+b.data[x].id+"/reactions",{access_token:toket,type:aing.type});
  55.             if(e.success){Logger.log(b.data[x].id+" -> OK")}else{Logger.log(b.data[x].id+" -> ERROR")}
  56.           }
  57.         }
  58.       }
  59.     }else{Logger.log(a.error.message);aing.sp.setProperty("toket","")}
  60.   }else{aing.ambilToket()}
  61. }
Add Comment
Please, Sign In to add comment