Skip to content

Instantly share code, notes, and snippets.

@hypnguyen1209
Created August 9, 2020 13:46
Show Gist options
  • Save hypnguyen1209/725c021af61751c83273afd628c4cb44 to your computer and use it in GitHub Desktop.
Save hypnguyen1209/725c021af61751c83273afd628c4cb44 to your computer and use it in GitHub Desktop.
/**
* @author hypnguyen1209
*/
/* Switch to new Facebook */
(()=>{let e=document.querySelectorAll('[data-type="type_user"]')[0].dataset.navItemId,t=document.getElementsByName("fb_dtsg")[0].value;fetch("https://www.facebook.com/comet/try/",{headers:{accept:"*/*","accept-language":"vi-VN,vi;q=0.9,fr-FR;q=0.8,fr;q=0.7,en-US;q=0.6,en;q=0.5","content-type":"application/x-www-form-urlencoded","sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"same-origin","viewport-width":"1920"},referrer:"https://www.facebook.com/",referrerPolicy:"origin-when-cross-origin",body:`source=SETTINGS_MENU&nctr[_mod]=pagelet_bluebar&__user=${e}&__a=1dpr=1&fb_dtsg=${encodeURIComponent(t)}`,method:"POST",mode:"cors",credentials:"include"}).then(()=>console.log("Done!")).catch(e=>console.error(e))})();
/* Switch to classic Facebook */
(()=>{let e=document.body.getElementsByTagName("script")[6].innerText.match(/\"USER_ID\":\"(.*?)\",\"/m)[1];let t=(()=>{let e=document.body.getElementsByTagName("script");for(let t=0;t<e.length;t++)if(e[t].innerText.includes("fb_dtsg"))return e[t].innerText.match(/\"name\":\"fb_dtsg\",\"value\":\"(.*?)\"}/m)[1]})();fetch("https://www.facebook.com/api/graphql/",{headers:{accept:"*/*","accept-language":"vi-VN,vi;q=0.9,fr-FR;q=0.8,fr;q=0.7,en-US;q=0.6,en;q=0.5","content-type":"application/x-www-form-urlencoded","sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"same-origin","viewport-width":"1920"},referrer:"https://www.facebook.com/",referrerPolicy:"no-referrer-when-downgrade",body:`av=${e}&__user=${e}&__a=1&dpr=1&fb_dtsg=${encodeURIComponent(t)}&fb_api_caller_class=RelayModern&fb_api_req_friendly_name=CometTrialParticipationChangeMutation&variables=%7B%22input%22%3A%7B%22change_type%22%3A%22OPT_OUT%22%2C%22source%22%3A%22SETTINGS_MENU%22%2C%22actor_id%22%3A%22${e}%22%2C%22client_mutation_id%22%3A%221%22%7D%7D&server_timestamps=true&doc_id=2317726921658975`,method:"POST",mode:"cors",credentials:"include"}).then(()=>console.log("Done!")).catch(e=>console.error(e))})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment