Skip to content

Instantly share code, notes, and snippets.

@monokaijs
Last active July 7, 2023 18:03
Show Gist options
  • Star 25 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save monokaijs/270e29620c46cabec1caca8c3746729d to your computer and use it in GitHub Desktop.
Save monokaijs/270e29620c46cabec1caca8c3746729d to your computer and use it in GitHub Desktop.
A small snippet to help you download Facebook video at ease...
/**
** Author: @MonokaiJs
** Contact: monokaijs@northstudio.vn | https://fb.me/monokaijssss | monokaijs.com
**
** Free to use, but don't abuse :>
**/
(()=>{let a=location.href.match(/\/(?:videos|reel|watch)(?:\/?)(?:\?v=)?(\d+)/);if(a.length<2){console.log("Please open a video before running this script.");return}let c=function(d,e){let f=[],a;for(a in d)if(d.hasOwnProperty(a)){let g=e?e+"["+a+"]":a,b=d[a];f.push(null!==b&&"object"==typeof b?c(b,g):encodeURIComponent(g)+"="+encodeURIComponent(b))}return f.join("&")},b=function(a,b){return fetch("https://www.facebook.com/api/graphql/",{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:c({doc_id:a,variables:JSON.stringify(b),fb_dtsg:require("DTSGInitialData").token,server_timestamps:!0})})};console.log("Getting info..."),b("5279476072161634",{UFI2CommentsProvider_commentsKey:"CometTahoeSidePaneQuery",caller:"CHANNEL_VIEW_FROM_PAGE_TIMELINE",displayCommentsContextEnableComment:null,displayCommentsContextIsAdPreview:null,displayCommentsContextIsAggregatedShare:null,displayCommentsContextIsStorySet:null,displayCommentsFeedbackContext:null,feedbackSource:41,feedLocation:"TAHOE",focusCommentID:null,privacySelectorRenderLocation:"COMET_STREAM",renderLocation:"video_channel",scale:1,streamChainingSection:!1,useDefaultActor:!1,videoChainingContext:null,videoID:a[1]}).then(a=>a.text()).then(b=>{try{let a=JSON.parse(b.split("\n")[0]),c=a.data.video.playable_url_quality_hd||a.data.video.playable_url;console.clear(),console.log("\u2705 Successfully retrieved download link."),console.log("======================="),console.log("%cClick this link to download: "+c,"color: green"),console.log("If your browser does not download automatically, please press Ctrl+S on your keyboard after followed the link above."),console.log("======================="),console.log("\u{1F37A} If you like my tool, gimme a follow at https://fb.me/monokaijssss !! Thank yeww <3")}catch(d){console.log("\u26A0\uFE0FFailed to extract data. Maybe this script is no longer effective.")}}).catch(a=>{console.error("\u26A0\uFE0FFailed to get data")})})()
@charisdang
Copy link

Cảm ơn Nhân nhìu

@ductong169z
Copy link

nice bro

@nghiepdev
Copy link

Cũng có thể tạo Bookmark không cần mở DevTools luôn nhé

javascript:(()=>{let e=location.href.match(/\/(?:videos|reel|watch)(?:\/?)(?:\?v=)?(\d+)/);if(!e||e.length<2)return void alert("Please open a video before running this script.");let o=function(e,t){let n,l=[];for(n in e)if(e.hasOwnProperty(n)){let a=t?t+"["+n+"]":n,i=e[n];l.push(null!==i&&"object"==typeof i?o(i,a):encodeURIComponent(a)+"="+encodeURIComponent(i))}return l.join("&")};console.log("Getting info..."),function(e,t){return fetch("https://www.facebook.com/api/graphql/",{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:o({doc_id:e,variables:JSON.stringify(t),fb_dtsg:require("DTSGInitialData").token,server_timestamps:!0})})}("5279476072161634",{UFI2CommentsProvider_commentsKey:"CometTahoeSidePaneQuery",caller:"CHANNEL_VIEW_FROM_PAGE_TIMELINE",displayCommentsContextEnableComment:null,displayCommentsContextIsAdPreview:null,displayCommentsContextIsAggregatedShare:null,displayCommentsContextIsStorySet:null,displayCommentsFeedbackContext:null,feedbackSource:41,feedLocation:"TAHOE",focusCommentID:null,privacySelectorRenderLocation:"COMET_STREAM",renderLocation:"video_channel",scale:1,streamChainingSection:!1,useDefaultActor:!1,videoChainingContext:null,videoID:e[1]}).then((e=>e.text())).then((e=>{try{let o=JSON.parse(e.split("\n")[0]),t=o.data.video.playable_url_quality_hd||o.data.video.playable_url;console.clear(),console.log("✅ Successfully retrieved download link."),console.log("======================="),console.log("%cClick this link to download: "+t,"color: green"),console.log("If your browser does not download automatically, please press Ctrl+S on your keyboard after followed the link above."),console.log("======================="),console.log("🍺 If you like my tool, gimme a follow at https://fb.me/monokaijssss !! Thank yeww <3"),window.open(t)}catch(e){alert("Failed to extract data. Maybe this script is no longer effective."+e.message)}})).catch((e=>{alert("⚠️Failed to get data "+e.message)}))})();

@DatVu-Hust
Copy link

cảm ơn anh Nhân nhiều 💯

@Darkknight-kgb
Copy link

Thanks bro

@duongkpro
Copy link

tkanks bro

@ZeraKage
Copy link

ZeraKage commented Sep 4, 2022

thanks bro

@realies
Copy link

realies commented Apr 19, 2023

thanks bro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment