Workaround for SecurePrivacy issues with VPNs (#357)

* workaround for secureprivacy issues with vpn

* fix flow issues
This commit is contained in:
mayeaux 2021-11-23 23:26:23 +01:00 committed by GitHub
parent f8b694d7d7
commit 84e75fdfe8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -336,12 +336,18 @@ function App(props: Props) {
// might use this for future checking to prevent doubleloading // might use this for future checking to prevent doubleloading
script.id = 'securePrivacy'; script.id = 'securePrivacy';
const cmpScript = document.createElement('script');
cmpScript.src = 'https://app.secureprivacy.ai/secureprivacy-plugin/web-plugin/cmp/cmp-v2.js';
cmpScript.async = true;
const getLocaleEndpoint = 'https://api.odysee.com/locale/get'; const getLocaleEndpoint = 'https://api.odysee.com/locale/get';
const gdprRequired = localStorage.getItem('gdprRequired'); const gdprRequired = localStorage.getItem('gdprRequired');
// gdpr is known to be required, add script // gdpr is known to be required, add script
if (gdprRequired === 'true') { if (gdprRequired === 'true') {
// $FlowFixMe // $FlowFixMe
document.head.appendChild(script); document.head.appendChild(script);
// $FlowFixMe
document.head.appendChild(cmpScript);
} }
// haven't done a gdpr check, do it now // haven't done a gdpr check, do it now
@ -355,6 +361,8 @@ function App(props: Props) {
localStorage.setItem('gdprRequired', 'true'); localStorage.setItem('gdprRequired', 'true');
// $FlowFixMe // $FlowFixMe
document.head.appendChild(script); document.head.appendChild(script);
// $FlowFixMe
document.head.appendChild(cmpScript);
// note we don't need gdpr, save to session // note we don't need gdpr, save to session
} else if (gdprRequiredBasedOnLocation === false) { } else if (gdprRequiredBasedOnLocation === false) {
localStorage.setItem('gdprRequired', 'false'); localStorage.setItem('gdprRequired', 'false');
@ -365,6 +373,8 @@ function App(props: Props) {
return () => { return () => {
// $FlowFixMe // $FlowFixMe
document.head.removeChild(script); document.head.removeChild(script);
// $FlowFixMe
document.head.appendChild(cmpScript);
}; };
}, []); }, []);