maxmind-geoip.js (1574B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 /** 8 * Bug 1754389 - Shim Maxmind GeoIP library 9 * 10 * Some sites rely on Maxmind's GeoIP library which gets blocked by ETP's 11 * fingerprinter blocking. With the library window global not being defined 12 * functionality may break or the site does not render at all. This shim 13 * has it return the United States as the location for all users. 14 */ 15 16 if (!window.geoip2) { 17 const continent = { 18 code: "NA", 19 geoname_id: 6255149, 20 names: { 21 de: "Nordamerika", 22 en: "North America", 23 es: "Norteamérica", 24 fr: "Amérique du Nord", 25 ja: "北アメリカ", 26 "pt-BR": "América do Norte", 27 ru: "Северная Америка", 28 "zh-CN": "北美洲", 29 }, 30 }; 31 32 const country = { 33 geoname_id: 6252001, 34 iso_code: "US", 35 names: { 36 de: "USA", 37 en: "United States", 38 es: "Estados Unidos", 39 fr: "États-Unis", 40 ja: "アメリカ合衆国", 41 "pt-BR": "Estados Unidos", 42 ru: "США", 43 "zh-CN": "美国", 44 }, 45 }; 46 47 const city = { 48 names: { 49 en: "", 50 }, 51 }; 52 53 const callback = onSuccess => { 54 requestAnimationFrame(() => { 55 onSuccess({ 56 city, 57 continent, 58 country, 59 registered_country: country, 60 }); 61 }); 62 }; 63 64 window.geoip2 = { 65 country: callback, 66 city: callback, 67 insights: callback, 68 }; 69 }