Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.