Skip to content

Instantly share code, notes, and snippets.

@kingcos
Created October 21, 2019 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kingcos/a6581f584b82209bc5b35ad12f249acf to your computer and use it in GitHub Desktop.
Save kingcos/a6581f584b82209bc5b35ad12f249acf to your computer and use it in GitHub Desktop.
Calculate the active count in App Store Connect
function active_count_lower_than(target_version) {
target_version = target_version
.split(".")
.map(e => {
if (e.length < 2) {
return "0" + e;
} else {
return e;
}
})
.join(".");
console.log("Formatted Target Version is ", target_version);
var sum = 0;
tr_elements = [].filter.call(
document.getElementsByTagName("tr"),
el => el.className == "ng-scope"
);
versions = [].map.call(tr_elements, el =>
el
.getElementsByClassName("title ng-binding")[0]
.innerHTML.replace(" (iOS)", "")
);
counts = [].map.call(tr_elements, el =>
Number(
el
.getElementsByClassName("ng-scope ng-binding")[0]
.innerHTML.replace(",", "")
)
);
versions.forEach(function(value, index, array) {
version = value
.split(".")
.map(e => {
if (e.length < 2) {
return "0" + e;
} else {
return e;
}
})
.join(".");
if (version < target_version) {
sum += counts[index];
console.log("Calculating version: ", version);
} else {
console.log("Skipping version: ", version);
}
});
return sum;
}
// Example:
active_count_lower_than("8.8.0")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment