Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A following analysis script for Mastodon.

Mastodon Follower Analysis

A rough Mastodon follower origin analysis script.

Operation

  1. Zoom out Mastodon all the way so all following are on screen.
  2. Copy and paste follow_analysis.js's contents into the JS console.
  3. Set your mode. If you want to analyze followers, set mode to 2, and 1 if you want to analyze following.
  4. Select the appropiate tab (follower/following) in Mastodon.
  5. Run it by pressing Enter.
  6. All data will be printed to console.

Note: Uses various code snippets from StackOverflow, including:

License

MIT.

var mode = 1
// mode 1: following
// mode 2: followers
if(mode == 1) {
console.warn ("Followed Users Breakdown:")
} else if(mode == 2) {
console.warn ("Follower Breakdown:")
}
var ar = []
var entries = document.querySelectorAll(".item-list>article>.account>.account__wrapper>a>.display-name>.display-name__account")
for(i=0;i<entries.length;i++) {
try {
ar.push(/(@.*@)(.*\..*)/.exec(entries[i].innerHTML)[2])
} catch(err) {}
}
var home = (Number(document.querySelectorAll(".account__action-bar__tab>strong>span")[mode].innerHTML))-ar.length
console.info("Remote Follows: " + ar.length + "\nHome Follows: " + home + "\n")
var counts = JSON.parse(`{"${window.location.host}": ${home}}`);
ar.forEach(function(x) { counts[x] = (counts[x] || 0)+1; });
for (var key in counts) {
console.log(key, counts[key], Math.floor((counts[key]/ar.length)*100) + "%");
}
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.