Last active
September 2, 2019 10:44
-
-
Save monokaijs/9ac452498e4912fe45b8985c77ca577d to your computer and use it in GitHub Desktop.
Unlike all your liked pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(() => { | |
/* | |
* | |
* @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