Skip to content

Instantly share code, notes, and snippets.

@monokaijs
Last active September 2, 2019 10:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save monokaijs/9ac452498e4912fe45b8985c77ca577d to your computer and use it in GitHub Desktop.
Save monokaijs/9ac452498e4912fe45b8985c77ca577d to your computer and use it in GitHub Desktop.
Unlike all your liked pages
(() => {
/*
*
* @author: MonokaiJs
* @facebook: fb.me/MonokaiJsp
*
*/
const ACCESS_TOKEN = 'EAAAA-put-your-access-token-here';
let xhr = new XMLHttpRequest;
xhr.open('GET', `https://graph.facebook.com/me/likes?access_token=${ACCESS_TOKEN}`);
xhr.send();
xhr.onreadystatechange = () => {
if (xhr.readyState == 4) {
let list = JSON.parse(xhr.responseText);
list.data.forEach(page => {
let unlikePage = page;
let unlikeRequest = new XMLHttpRequest;
unlikeRequest.open('DELETE', `https://graph.facebook.com/${unlikePage.id}/likes?access_token=${ACCESS_TOKEN}`);
unlikeRequest.send();
unlikeRequest.onreadystatechange = () => {if (unlikeRequest.readyState == 4) { console.log(`Unliked ${unlikePage.name}`); }}
});
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment