Need Help with Visitors GEO Location Script

MGaLL

Junior Member
Joined
Mar 24, 2022
Messages
168
Reaction score
159
Code:
var id = "";
        var username = "";
        var country, flagurl = "";
        fetch('https://cloudflare-quic.com/b/headers').then(res=>res.json()).then(data=>{let regionNames = new Intl.DisplayNames(['en'], {type: 'region'}); country = regionNames.of(data.headers['Cf-Ipcountry']); flagurl = "https://ip-api.io/images/flags/"+data.headers['Cf-Ipcountry'].toLowerCase()+".svg"; document.getElementById("flagos").src=flagurl;})
//    $.getJSON("country.php", function (response) {
//    var code = response["country"];
    
//        let regionNames = new Intl.DisplayNames(['en'], {type: 'region'});
//        country = regionNames.of(code);
        
//        flagurl = "https://ip-api.io/images/flags/"+code.toLowerCase()+".svg";
//        document.getElementById("flagos").src=flagurl;
//});

Hello, I got this script from somewhere and it used to work but not anymore.

Seems that this cloudflare-quic link is the thing that stopped it. https://cloudflare-quic.com/b/headers

Wayback machine has scraped this page many times in past, but I am unable to recover this file for now.

https://web.archive.org/web/20220000000000*/https://cloudflare-quic.com/b/headers
If anybody could help I would really appreciate. Thanks!
 
Bump

is there a way to recreate this code from cloudflare headers?

I think that only reading visitors IP should be enough to display the country flag on a website, since the rest of code works?

Or could you suggest me how to display visitors flags only?

Thanks.
 
Have you been able to solve this problem?
 
You can create a cloudflare worker that would respond with the necessary header (Cf-Ipcountry). Let me know if you still need this and I'll reply with the code.
 
Back
Top