Created
April 9, 2020 17:17
-
-
Save Tylerian/abe522e95b31e4b42fa64a4ebabdf04a to your computer and use it in GitHub Desktop.
Dialing Codes Generator
This file contains hidden or 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
/// 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