Skip to content

Instantly share code, notes, and snippets.

@thecooldaniel
Last active March 20, 2018 23:32
Show Gist options
  • Save thecooldaniel/8f1fd392ce6f7cc00825589832ab6dbb to your computer and use it in GitHub Desktop.
Save thecooldaniel/8f1fd392ce6f7cc00825589832ab6dbb to your computer and use it in GitHub Desktop.
Infusionsoft Top 25% Tags
// Generates your top 25% used tags in Infusionsoft.
// Must be at a URL which displays tags, and have the number of uses for each tag shown (you must click "show")
function toptf() {
var sum = [];
jQuery("tr.data-td, tr.alt-data-td").each(function(){
var node = {};
node.name = jQuery(this).find("td:nth-child(3)").text();
node.num = parseInt(jQuery(this).find("td:nth-child(5)").text());
sum.push(node);
return sum;
})
for( i=0; i < sum.length; i++) {
for(k = 0; k < sum.length - i; k++ ) {
if( k < (sum.length - 1)) {
if( sum[k].num > sum[k+1].num ) {
var tmp = sum[k];
sum[k] = sum[k+1];
sum[k+1] = tmp;
}
}
}
}
var top_twenty_five = Math.ceil(sum.length / 4);
console.log("Your top 25% tags:");
for( i=(sum.length - top_twenty_five); i < sum.length; i++) {
console.log((sum.length - i)+". "+sum[i].name+" ("+sum[i].num+")");
}
}
toptf();
/**
Output:
Your top 25% tags:
10. Libido (403)
9. Hair Loss (433)
8. Allergies (455)
7. Insomnia (466)
6. Menopause (519)
5. Arthritis (540)
4. Fatigue (637)
3. High Blood Pressure (646)
2. Weight Gain (739)
1. Cholesterol (744)
**/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment