Skip to content

Instantly share code, notes, and snippets.

@robbiet480
Created June 20, 2019 22:18
Show Gist options
  • Save robbiet480/e240030db78801f02cf12be3709be706 to your computer and use it in GitHub Desktop.
Save robbiet480/e240030db78801f02cf12be3709be706 to your computer and use it in GitHub Desktop.
A lil script to collect all of your Instagram ad interests automatically so you don't have to keep clicking "Show More".
// 1. On your computer, go to https://www.instagram.com/accounts/access_tool/ads_interests
// 2. Open dev tools by right clicking on the page and selecting "Inspect"
// 3. Click Console
// 4. Paste the following code
// 5. Hit enter
// 6. Wait
// 7. It will print out your list of interests once its done.
var allInterests = [];
function getPage(cursor) {
var xmlhttp = new XMLHttpRequest();
var url = "https://www.instagram.com/accounts/access_tool/ads_interests?__a=1&cursor="+cursor;
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var resp = JSON.parse(this.responseText);
var interestStrings = resp.data.data.map(function(elm){ return elm.text; });
allInterests = allInterests.concat(interestStrings);
if(resp.data.cursor) {
getPage(resp.data.cursor);
} else {
console.log('All interests', allInterests.join(", "));
}
}
};
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
getPage("0");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment