Skip to content

Instantly share code, notes, and snippets.

View merlijnvanlent's full-sized avatar

Merlijn van Lent merlijnvanlent

View GitHub Profile
const userAgent = window.navigator.userAgent;
const consentCookie = []; // Set the current consent status if this is a returning visitor.
const attRejectedString = 'ATTRejected';
const attAcceptedString = 'ATTAccepted';
// Show the consent bar if the consent cookie is not set or if this is the in-app browser
const initConsentBar = () => {
if (consentCookie.length > 0) {
return; // Tracking consent was already given by the visitor.
///
/// And you would use this like so in your app's codebase:
///
let webView = WKWebView()
webView.setCustomUserAgent(.att(self.isATTAccepted ? .accepted : .rejected))
import WebKit
extension WKWebView {
/// WKWebView.customUserAgent value
enum CustomUserAgent {
/// ATT (App Tracking Transparency)
/// - ATTUserAgent: set this based on users ATT preferences
case att(ATTUserAgent)
}
/// ATTUserAgent possible values
// change these vars until your satisfied MAKE SURE THAT THE CANVAS HAS AN ID OF: "Bounce" AND HAS THE SAME HEIGHT AND WIDTH AS YOU SPECIFY HERE
var WIDTH =1000 //height of canvas
var HEIGHT = 1000; // width of canvas
var balls = 501; // amount of balls
var size = 15; // radius of the balls
var canvas;
var ctx;
var x = [1];