Skip to content

Instantly share code, notes, and snippets.

@Tylerian
Created April 9, 2020 17:17
Show Gist options
  • Save Tylerian/abe522e95b31e4b42fa64a4ebabdf04a to your computer and use it in GitHub Desktop.
Save Tylerian/abe522e95b31e4b42fa64a4ebabdf04a to your computer and use it in GitHub Desktop.
Dialing Codes Generator
/// https://developers.facebook.com/docs/accountkit/countrycodes/
/// Run on Chrome Tools Console
var json = "[";
var table = document.getElementsByClassName("class_of_the_table")[0];
for (var i = 0, row; row = table.rows[i]; i++) {
json += "{";
for (var j = 0, col; col = row.cells[j]; j++) {
if (j === 0) {
json += "\"flag\": \"\", "
} else if (j === 1) {
json += "\"dial\": " + col.innerText + ", "
} else if (j === 2) {
json += "\"country\": \"" + col.innerText + "\""
}
}
json += "},"
}
json += "]";
console.log(json);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment