Skip to content

Instantly share code, notes, and snippets.

@wmh
Last active September 11, 2017 02:04
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 wmh/e09decf6bc2d2ef06e88a64382c58277 to your computer and use it in GitHub Desktop.
Save wmh/e09decf6bc2d2ef06e88a64382c58277 to your computer and use it in GitHub Desktop.
Get MCC List by jQuery
// https://github.com/musalbas/mcc-mnc-table/blob/master/mcc-mnc-table.csv
var mccs={};
document.querySelectorAll('table.js-csv-data > tbody > tr > td:nth-child(2)').forEach(function (ele) {
mccs[ele.innerText] = 1;
});
Object.keys(mccs).join(',');
// https://en.wikipedia.org/wiki/Mobile_country_code
var mcc = {}
$('table.wikitable').each(function (idx, t) {
var $t = $(t),
$th = $t.find('th:nth-child(1)');
if ($th.length === 0) {
return;
}
if ($th[0].innerText != 'MCC') {
return;
}
var $td = $t.find('tr td:nth-child(1)');
if ($td.length === 0) {
return;
}
var tdLen = $td.length;
for (var i = 0; i < tdLen; ++i) {
var m = $.trim($td[i].innerText);
if (m === '') {
continue;
}
mcc[m] = 1;
}
});
console.log("'" + Object.keys(mcc).join("','") + "'")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment