Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KhunHtetzNaing/8102638f84281097dd32c0aba09bac5d to your computer and use it in GitHub Desktop.
Save KhunHtetzNaing/8102638f84281097dd32c0aba09bac5d to your computer and use it in GitHub Desktop.
Get all video + audio from facebook dash
if (document.body.textContent) {
get_all_video();
get_audio();
}
function parseURL(url) {
if (url == null) {
return null;
}
return url.replace(/amp;/g, '');
}
function get_audio() {
var regex = /\/>\\x3CBaseURL>(.*?)\\x3C/gm,
str = document.body.textContent,
m;
if ((m = regex.exec(str)) !== null) {
return parseURL(m[1]);
}
return null;
}
function get_all_video() {
var regex = /FBQualityClass=\\"(.*?)\\" ?FBQualityLabel=\\"(.*?)\\">\\x3CBaseURL>(.*?)\\x3C/gm,
str = document.body.textContent,
m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
var group = m[1],
quality = m[2],
url = parseURL(m[3]);
console.log(group, quality, url);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment