Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the script CSP compliant #194

Closed
emilebosch opened this issue Sep 21, 2022 · 7 comments · Fixed by #200
Closed

Make the script CSP compliant #194

emilebosch opened this issue Sep 21, 2022 · 7 comments · Fixed by #200
Labels
bug Something isn't working enhancement New feature or request

Comments

@emilebosch
Copy link
Contributor

It uses new Function thus requiring CSP unsafe-eval.
Here Luckily only uses it in the browser detection section. Here is the patched code.

// CHECKING FOR SPECIFIC DEVICED AND SYSTEMS
// browser
const isBrowser = ()=>{try { return this===window; } catch(e) { return false; }}
// iOS
const isiOS = isBrowser()
  ? ()=>{
      if ((/iPad|iPhone|iPod/i.test(navigator.userAgent || navigator.vendor || window.opera) && !window.MSStream) || (navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1)) { return true; } else { return false; }
    }
  : ()=>{return false;}
// Android
const isAndroid = isBrowser()
  ? ()=>{
      if (/android/i.test(navigator.userAgent || navigator.vendor || window.opera) && !window.MSStream) { return true; } else { return false; }
    }
  : ()=>{return false;};
// Chrome
const isChrome = isBrowser()
  ? ()=>{
      if (/chrome|chromium|crios/i.test(navigator.userAgent)) { return true; } else { return false; }
    }
  : ()=>{return false;};
// Mobile
const isMobile = () => {
  if (isAndroid() || isiOS()) {
    return true;
  } else {
    return false;
  }
};
// WebView (iOS and Android)
const isWebView = isBrowser()
  ? ()=>{
      if (/(; ?wv|(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari))/i.test(navigator.userAgent || navigator.vendor)) { return true; } else { return false; }
    }
  : ()=>{return false;};
// checking for problematic apps
const isProblematicWebView = isBrowser()
  ? ()=>{
      if (/(Instagram)/i.test(navigator.userAgent || navigator.vendor || window.opera)) { return true; } else { return false; }
    }
  : ()=>{return false;};
@jekuer
Copy link
Collaborator

jekuer commented Sep 21, 2022

Thanks a lot!
Will look into it.

@jekuer
Copy link
Collaborator

jekuer commented Sep 21, 2022

Do you want to push this as a pull request? Would make you shine up as contributor. Otherwise, I will simply patch it in a few days.

@emilebosch
Copy link
Contributor Author

I had to quickly hack this together for our web team since it was killing their buttons. Here is sloppy pr sorry about that

#195

@emilebosch
Copy link
Contributor Author

If you could release a version on js deliver you'd make our webflow based web team super happy

@jekuer
Copy link
Collaborator

jekuer commented Sep 21, 2022

will check and release. however, might take ~1 week

@emilebosch
Copy link
Contributor Author

thank you 🙌

@jekuer jekuer linked a pull request Oct 1, 2022 that will close this issue
Merged
2 tasks
@jekuer jekuer added bug Something isn't working enhancement New feature or request labels Oct 1, 2022
@jekuer
Copy link
Collaborator

jekuer commented Oct 1, 2022

Included in new Version 1.16 - thanks again! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants