Created
October 21, 2019 06:23
-
-
Save kingcos/a6581f584b82209bc5b35ad12f249acf to your computer and use it in GitHub Desktop.
Calculate the active count in App Store Connect
This file contains 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
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