Advertisement
rg443

geojs table

Aug 12th, 2020
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var _iplist=Array.from(new Set(document.body.innerHTML.match(/\d+\.\d+\.\d+\.\d+/g)));
  2. function aa(){x=_iplist.splice(0,100);fetch("https://get.geojs.io/v1/ip/geo.json?ip="+x.join(','),{method:"get"}).then(function(r){return r.status==200? r.json():{}}).then(function(d){if(_iplist.length>0){aa()}else { console.log("done");};
  3. var td,tr;for (var ii of d) {tr=document.createElement("tr");tbody.appendChild(tr);
  4. for (var i of ['ip','country','city','organization','timezone','accuracy',,'latitude','longitude','continent_code','country_code','country_code3']) {
  5. td=document.createElement("td");tr.appendChild(td);td.innerHTML=ii[i]||'';
  6. //if (i=='country') {td.style.background='url(https://lipis.github.io/flag-icon-css/flags/4x3/' + (ii.country_code||ii.continent_code).toLowerCase() + '.svg)';td.style.backgroundSize="contain";td.style.backgroundRepeat="no-repeat";td.style.paddingLeft="24px"; }
  7.  
  8.  }}
  9. }).catch(function(err){aa();})}
  10.  
  11. var tab1=document.createElement("table"),tbody=document.createElement("tbody");tab1.appendChild(tbody);document.body.appendChild(tab1);tab1.style.font="11px monospace";tab1.style.marginLeft="70px";
  12. aa();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement