JSFiddle - React, Tailwind, and code Playground
HTML
<div>
Check whether domain is using Gsuite or not. <br>
Input domain separated by 'enter', e.g:
<pre>
atlassian.com
dell.com
abc.com
</pre>
</div>
<form id="main-form" action="#">
<textarea id="input-domain" cols="30" rows="10" placeholder="input domain separated by 'enter', e.g: ibm.com">
notexist.com
notusingGsuite.com
abc.com
verizon.com
atlassian.com
wikipedia.com
google.com
dell.com</textarea>
<br>
<input type="submit" value="check!">
</form>
<pre id="output"></pre>
<script>
var result = {};
function isUsingGsuiteBulk(inputs, onEachImageLoaded = function(){}){
let temp = {};
let temp2 = [];
inputs.map((el,idx)=>{
temp["img-"+idx] = new Image();
temp2[idx] = {};
temp2[idx].url = el;
temp["img-"+idx].onload = function() {
// console.log(this);
if(this.width == 122 && this.height == 30){
temp2[idx].isUsingGsuite = 0;
}else {
temp2[idx].isUsingGsuite = 1;
}
temp2[idx].width = this.width;
temp2[idx].height = this.height;
onEachImageLoaded(temp2[idx]);
}
let imgSrc = 'https://www.google.com/a/cpanel/'+el+'/images/logo.gif?service=gmail';
temp["img-"+idx].src = imgSrc;
temp2[idx].imgSrc = imgSrc;
});
return temp2;
}
document.querySelector('#main-form').onsubmit = function checkDomain(e){
e.preventDefault();
var inputDomain = document.querySelector('#input-domain');
var output = document.querySelector('#output');
var domains = inputDomain.value.split("\n");
result = isUsingGsuiteBulk(domains,function(el){
output.innerText = JSON.stringify(result, null, 2)
});
return false
}
</script>