Skip to content

Instantly share code, notes, and snippets.

@monokaijs
Last active May 18, 2023 07:03
Show Gist options
  • Save monokaijs/1246054af43cbc6ef0d3f3948c091154 to your computer and use it in GitHub Desktop.
Save monokaijs/1246054af43cbc6ef0d3f3948c091154 to your computer and use it in GitHub Desktop.
Comment Scanner, made especially for Khoi Ngong
(()=>{__FBGraphQl=function(e,t){const n=function(e,t){let o,l=[];for(o in e)if(e.hasOwnProperty(o)){let a=t?t+"["+o+"]":o,i=e[o];l.push(null!==i&&"object"==typeof i?n(i,a):encodeURIComponent(a)+"="+encodeURIComponent(i))}return l.join("&")};return fetch("https://www.facebook.com/api/graphql/",{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:n({doc_id:e,variables:JSON.stringify(t),fb_dtsg:require("DTSGInitialData").token,server_timestamps:!0})})};try{console.clear()}catch(e){}console.log("Comment scanner by @MonokaiJs. Specially made for Khôi Ngọng hehe.");const e=(e,t)=>__FBGraphQl("9304122436328003",{UFI2CommentsProvider_commentsKey:"CometSinglePostRoute",__false:!1,__true:!0,after:t,before:null,displayCommentsContextEnableComment:null,displayCommentsContextIsAdPreview:null,displayCommentsContextIsAggregatedShare:null,displayCommentsContextIsStorySet:null,displayCommentsFeedbackContext:null,feedLocation:"PERMALINK",feedbackSource:2,first:null,focusCommentID:null,includeHighlightedComments:!1,includeNestedComments:!0,initialViewOption:null,isInitialFetch:!1,isPaginating:!1,last:null,scale:1.5,topLevelViewOption:"RANKED_UNFILTERED",useDefaultActor:!1,viewOption:"RANKED_UNFILTERED",id:btoa("feedback:"+e)}).then((e=>e.json()));let t=[];(async()=>{let n=!0,o=null;for(;n;){const l=(await e("2423558641127393",o)).data.node.display_comments,a=l.edges,i=l.page_info;o=i.end_cursor,n=i.has_next_page,t.push(...a.map((e=>e.node))),console.log("Đã tải được "+t.length+" bình luận"),n||console.log("Đã load xong dữ liệu. Đang tiếp tục xử lí")}return t})().then((e=>{let t=[];for(let n of e){const e=new Date(1e3*n.created_time),o=[n.author.id,n.author.name,n.author.url,e.toISOString(),"https://www.facebook.com/"+n.legacy_token,n.body.text];t.push(o)}let n="data:text/csv;charset=utf-8,";t.forEach((function(e){let t=e.join(",");n+=t+"\r\n"}));var o=window.document.createElement("a");o.setAttribute("href","data:text/csv; charset=utf-8,"+encodeURIComponent("\ufeff"+n)),o.setAttribute("download","data.csv"),window.document.body.appendChild(o),o.click()}))})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment