Just a quick note regarding the usage of navigator.window.languages: this variable will return all languages set in the browser. For example, in Google Chrome, if a user has set the browser to "Never translate French" (or any other European language), that language will be automatically added to the list returned by navigator.languages.
This means that, even if the user is in a country where the GDPR doesn't apply, the popup will still be shown. Just think about all the European expats around the world :)
A better option would be to only use the main browser language returned by window.navigator.language.