var pbApiHost = 'https://api.privacybee.com'; var pbTrustHost = 'https://trust.privacybee.com/'; var pbAppHost = 'https://app.privacybee.com'; var pbHomeHost = 'https://privacybee.com'; var pbAuthHost = 'https://auth.privacybee.com'; var pbVccContainer = null; var pbJq = null; var customHtml = `
Privacy Bee
Vendor & Cookie Consent
Previously configured?
Previously configured?
Company
Category
Trust & Consent
`; var signupContainer = `
Remember Your
Privacy Choices?
Join in seconds for free and see fewer “cookie popups” across and thousands of other websites!
or continue with
Already a member? Login Here
X
Save Your Cookie Preferences Across Thousands of Websites
- plus -
Free Data Privacy Exposure Scan
Less Telemarketing & Spam
Fewer Annoying Cookie Banners
`; var showHelp = `

How does this work?

respects our visitors' privacy, so we have partnered with Privacy Bee to offer vendor-level consent and preferences management. In compliance with various privacy laws, we will not load any script or store any cookie from any 3rd parties without your advance acceptance. Out of respect for your experience on our website, if we have previously received your consent from every vendor present on a page, we will use those previous preferences instead of showing this dialog again.

  • Temporarily permit loading (24 hours)

  • Trust Company (remember & don’t ask again)

  • Block Company (remember & don’t ask again)

` var vendorRow = `

`; var allowToggle = `
`; var trustToggle = `
`; var blockToggle = `
`; var requiredToggle = `
Required
`; let vendors = []; let loggedIn = false; let pbKey = null; let containerId = null; let token = null; let slug = null; let name = null; let url = null; let logo = null; let allData = {}; // Main Function function initPrivacyBeeVendorCookieConsent(settings) { if (!settings.container_id) { console.log('Privacy Bee Error - Vendor & Cookie Consent did not receive a Container ID in settings object.'); return; } containerId = settings.container_id; // If window has no jQuery, inject it! if (!window.jQuery || window.jQuery.fn.jquery !== '3.7.0' || typeof jQuery == 'undefined') { var script = document.createElement('script'); script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js'; script.type = 'text/javascript'; document.getElementsByTagName('head')[0].appendChild(script); // Wait for it... var pb_checkReady = function (callback) { if (window.jQuery && window.jQuery.fn.jquery === '3.7.0') { pbJq = $.noConflict(true); callback(jQuery); } else { window.setTimeout(function () { pb_checkReady(callback); }, 20); } }; pb_checkReady(function ($) { pbJq(function () { // jQuery is loaded... continue with VCC! privacyBeeVendorCookieConsent_loadContainer(settings.container_id, settings.container_data); }); }); } else { pbJq = window.jQuery; // Already has jQuery... proceed! privacyBeeVendorCookieConsent_loadContainer(settings.container_id, settings.container_data); } } function privacyBeeVendorCookieConsent_loadContainer(container_id, container_data) { pbJq('
', { id: 'pbvcc-container', style: 'display: none; position: absolute' }).appendTo('body'); pbJq('#pbvcc-container').append(customHtml); pbVccContainer = pbJq('#pbvcc-container'); pbVCC_injectCSS(`https://cdn.privacybee.com/vcc/templates/${container_data.vcc_template_id}.css`, container_data) } function pbVCC_injectCSS(css, container_data) { var link = document.createElement('link'); link.setAttribute("rel", "stylesheet"); link.setAttribute("type", "text/css"); link.onload = () => { privacyBeeVendorCookieConsent_containerRet(container_data) }; link.setAttribute("href", css); document.getElementsByTagName("head")[0].appendChild(link); } function privacyBeeVendorCookieConsent_containerRet(results, reload = false) { allData = results; if (allData['name']) { loggedIn = true; pbVCC_setLoggedInDisplay(results.name); } if (!results.vendors) { return; } pbVCC_processVendors(results.vendors); if ( !reload) { pbVCC_setTabsClickHandlers(); } const countOfSavedVendors = results.vendors.filter(function (vendor) { return vendor.trust; }).length; if (countOfSavedVendors === 0) { pbJq('#pbvcc-tabs').hide(); pbVCC_setNewVendors(); } else { pbJq('#pbvcc-tabs').show(); } if (typeof pbVCC_runCustomerSetup === "function") { // safe to use the function pbVCC_runCustomerSetup(); } pbVccContainer.show(); } function pbVCC_reloadContainer() { console.log('reload') var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == 200) { privacyBeeVendorCookieConsent_containerRet(JSON.parse(this.responseText).data, true); } else if (this.readyState == 4 && this.status != 200) { console.log('VCC Container was not found'); } }; xhttp.open('GET', pbApiHost + '/v1/vcc/load_container/' + containerId + '?domain=' + window.location.hostname, true); pbBusinessGateAuthString = decodeURI(document.cookie.match('(^|;)\\s*auth._token.pb\\s*=\\s*([^;]+)')?.pop()) || ''; xhttp.setRequestHeader('Authorization', pbBusinessGateAuthString) xhttp.setRequestHeader('Accept', 'application/json') xhttp.setRequestHeader('Accept', 'application/json'); xhttp.send(); } function pbVCC_getNewVendorsAvailable() { return this.vendors.filter(function (vendor) { if (vendor.required) { return false; } return !vendor.trust; }).length; } function pbVCC_redraw() { const countOfSavedVendors = this.vendors.filter(function (vendor) { if (vendor.required) { return false; } return vendor.trust; }).length; if (countOfSavedVendors === 0) { pbJq('#pbvcc-tabs').hide(); } else { pbJq('#pbvcc-tabs').show(); } } function pbVCC_processVendors(vendors) { let unset = 0; let orderedVendors = []; let required = []; let notRequired = []; // first sort Strictly Necessary to the bototm pbJq(vendors).each(function (key, vendor) { if (vendor.category === 'Strictly Necessary') { required.push(vendor); } else { notRequired.push(vendor); } }); orderedVendors = notRequired.concat(required); pbJq(orderedVendors).each(function (key, vendor) { vendor.trust_display = vendor.trust; var cookied = getCookie(`pb-vcc-${vendor.slug}`); if (vendor.category === 'Strictly Necessary') { pbVCC_injectScript(vendor); vendor.required = true; return; } vendor.required = false; if (vendor.trust === 'trusted') { pbVCC_injectScript(vendor); } else if (vendor.trust === 'negative') { if (cookied === 'allow') { vendor.trust = 'allow'; vendor.trust_display = 'allow'; pbVCC_injectScript(vendor); } } else if (cookied) { if (cookied === 'negative') { vendor.trust = 'negative'; vendor.trust_display = 'negative'; } else if (cookied === 'allow') { vendor.trust = 'allow'; vendor.trust_display = 'allow'; pbVCC_injectScript(vendor); } else if (cookied === 'trusted') { vendor.trust = 'trusted'; vendor.trust_display = 'trusted'; pbVCC_injectScript(vendor); } } else { unset++; } }); this.vendors = orderedVendors; } function pbVCC_buildRows(vendors) { pbJq('#pb-vcc-vendors-table').empty(); pbJq.each(vendors, function (key, vendor) { var element = pbJq(vendorRow); element.attr('id', vendor.slug); element.find('.pb-vcc-vendor-name-wrapper .pbvcc-vendor-name').text(vendor.name); element.find('.pb-vcc-vendor-logo img').attr('src', vendor.logo); element.find('.pb-vcc-vendor-name-wrapper .ext-link').attr('href', `${pbTrustHost}${vendor.slug}?aff=${token}`); element.find('.pb-vcc-vendor-category').text(vendor.category); element.find('.pb-vcc-vendor-name-wrapper').click(function (e) { e.stopPropagation(); pbVCC_loadVendorTrustPage(vendor.slug); }); if (!vendor.required) { // allow toggle var allow = pbJq(allowToggle); allow.find('input').attr('id', `allow_${vendor.slug}`); allow.find('label').attr('htmlFor', `allow_${vendor.slug}`); if (vendor.trust_display === 'allow') { allow.find('input.pbvcc-allow').attr('checked', 'checked'); } // trust toggle var trust = pbJq(trustToggle); trust.find('input').attr('id', `trust_${vendor.slug}`); trust.find('label').attr('htmlFor', `trust_${vendor.slug}`); if (vendor.trust_display === 'trusted') { trust.find('input.pbvcc-trust').attr('checked', 'checked'); } // block toggle var block = pbJq(blockToggle); block.find('input').attr('id', `block_${vendor.slug}`); block.find('label').attr('htmlFor', `block_${vendor.slug}`); if (vendor.trust_display === 'negative') { block.find('input.pbvcc-block').attr('checked', 'checked'); } element.find('.pb-vcc-vendor-options .pb-vcc-switch').append(allow).append(trust).append(block); pbVccContainer.find('#pb-vcc-vendors-table').append(element); pbJq(`#${vendor.slug}`).on('click', '.pbvcc-allow', function (b) { pbVCC_allowVendor(vendor.slug); }); pbJq(`#${vendor.slug}`).on('click', '.pbvcc-trust', function (b) { pbVCC_trustVendor(vendor.slug); }); pbJq(`#${vendor.slug}`).on('click', '.pbvcc-block', function (b) { pbVCC_blockVendor(vendor.slug); }); } else { var required = pbJq(requiredToggle); element.find('.pb-vcc-vendor-options .pb-vcc-switch').hide(); element.find('.pb-vcc-vendor-options').append(required); pbVccContainer.find('#pb-vcc-vendors-table').append(element); } }); } function pbVCC_checkIfAllVendorsSet() { const vendor = this.vendors.find((vendor) => { if (vendor.required) { return false; } return !vendor.trust; }); if ( !vendor && !loggedIn) { pbVccContainer.hide(); const signup = pbJq(signupContainer); pbJq('body').append(signup); signup.show(); } else if ( !vendor) { pbVccContainer.hide(); } } function pbVCC_allowVendor(slug) { const vendor = this.vendors.find((vendor) => { return vendor.slug === slug; }); if (vendor.trust_display === 'allow') { return; } vendor.trust_display = 'allow'; pbJq(`#${slug}`).find('input').attr('checked', false); pbJq(`#${slug}`).find('input.pbvcc-allow').attr('checked', true); pbVCC_showUpdateButtons(); } function pbVCC_trustVendor(slug) { const vendor = this.vendors.find((vendor) => { return vendor.slug === slug; }); if (vendor.trust_display === 'trusted') { return; } vendor.trust_display = 'trusted'; pbJq(`#${slug}`).find('input').attr('checked', false); pbJq(`#${slug}`).find('input.pbvcc-trust').attr('checked', true); pbVCC_showUpdateButtons(); } function pbVCC_blockVendor(slug) { const vendor = this.vendors.find((vendor) => { return vendor.slug === slug; }); if (vendor.trust_display === 'negative') { return; } vendor.trust_display = 'negative'; pbJq(`#${slug}`).find('input').attr('checked', false); pbJq(`#${slug}`).find('input.pbvcc-block').attr('checked', true); pbVCC_showUpdateButtons(); } function pbVCC_showUpdateButtons() { pbJq('#vcc-standard-buttons').hide(); pbJq('#vcc-update-buttons').show(); } function pbVCC_showStandardButtons() { pbJq('#vcc-standard-buttons').show(); pbJq('#vcc-update-buttons').hide(); } function pbVCC_setTabsClickHandlers() { pbJq('#pbvcc-new-vendors').on('click', function () { pbJq('#pbvcc-saved-vendors').removeClass('active'); pbJq('#pbvcc-new-vendors').addClass('active'); pbVCC_setNewVendors(); }); pbJq('#pbvcc-saved-vendors').on('click', function () { pbJq('#pbvcc-new-vendors').removeClass('active'); pbJq('#pbvcc-saved-vendors').addClass('active'); pbVCC_setSavedVendors(); }); } function pbVCC_setNewVendors() { var vendorsNew = this.vendors.filter(function (vendor) { return !vendor.trust; }); pbVCC_buildRows(vendorsNew); } function pbVCC_setSavedVendors() { var vendorsSaved = this.vendors.filter(function (vendor) { return vendor.trust; }); pbVCC_buildRows(vendorsSaved); } function pbVCC_savePreferences() { this.vendors.map(function (vendor) { vendor.trust = vendor.trust_display; if (vendor.trust === 'allow') { setCookie(`pb-vcc-${vendor.slug}`, 'allow', 1); } if (vendor.trust === 'trusted') { setCookie(`pb-vcc-${vendor.slug}`, 'trusted', 1); } if (vendor.trust === 'negative') { setCookie(`pb-vcc-${vendor.slug}`, 'negative', 1); } }); if (pbJq('#vcc-new-vendors').hasClass('active')) { pbVCC_setNewVendors(); } else { pbVCC_setSavedVendors(); } pbVCC_processScripts(); pbJq.ajax({ url: pbApiHost + '/v1/vcc/update_consent/' + containerId, type: 'post', data: { vendors: this.vendors, type: 'custom', }, dataType: 'json', headers: { Authorization: decodeURI(document.cookie.match('(^|;)\\s*auth._token.pb\\s*=\\s*([^;]+)')?.pop()) || '', }, }); pbVCC_redraw(); pbVCC_showStandardButtons(); pbVCC_checkIfAllVendorsSet(); } function pbVCC_cancelPreferences() { this.vendors.map(function (vendor) { vendor.trust_display = vendor.trust; }); if (pbJq('#pbvcc-new-vendors').hasClass('active')) { pbVCC_setNewVendors(); } else { pbVCC_setSavedVendors(); } pbVCC_showStandardButtons(); } function pbVCC_processScripts() { pbJq(this.vendors).each(function (key, vendor) { var scriptExists = pbJq(`#vcc_script_${vendor.slug}`).length; if (!scriptExists && (vendor.trust === 'allow' || vendor.trust === 'trusted')) { pbVCC_injectScript(vendor); } }); } function pbVCC_allowEssential() { pbJq(this.vendors).each(function (key, vendor) { if (!vendor.trust) { vendor.trust = 'negative'; vendor.trust_display = 'negative'; Cookies.set(`pb-vcc-${vendor.slug}`, 'negative', { expires: 1, domain: allData['domain'] }); } }); pbJq.ajax({ url: pbApiHost + '/v1/vcc/update_consent/' + containerId, type: 'post', data: { type: 'block_all', }, headers: { Authorization: decodeURI(document.cookie.match('(^|;)\\s*auth._token.pb\\s*=\\s*([^;]+)')?.pop()) || '', }, }); pbVCC_checkIfAllVendorsSet(); } function pbVCC_allowAll() { pbJq(this.vendors).each(function (key, vendor) { if (!vendor.trust) { vendor.trust = 'allow'; vendor.trust_display = 'allow'; setCookie(`pb-vcc-${vendor.slug}`, 'allow', 1); } else { setCookie(`pb-vcc-${vendor.slug}`, 'allow', 1); } var scriptExists = pbJq(`#vcc_script_${vendor.slug}`).length; if (!scriptExists) { pbVCC_injectScript(vendor); } }); pbJq.ajax({ url: pbApiHost + '/v1/vcc/update_consent/' + containerId, type: 'post', data: { type: 'allow_all', }, headers: { Authorization: decodeURI(document.cookie.match('(^|;)\\s*auth._token.pb\\s*=\\s*([^;]+)')?.pop()) || '', }, }); pbVCC_checkIfAllVendorsSet(); } function pbVCC_injectScript(vendor) { pbJq('body').append(vendor.script); } function pbVCC_loadPrivacyBee() { window.open(`${pbHomeHost}?aff=${token}`); } function pbVCC_Login(email = '') { let loginWindow = null; window.addEventListener('message', (e) => { if (!e.data.pb) { return; } const state = e.data.state; const code = e.data.code; if (state === localStorage.getItem('pb-state')) { var data = new FormData(); data.append('protocol', 'oauth2'); data.append('grant_type', 'authorization_code'); data.append('client_id', '9a6d0766-9534-43bd-84dc-8c575e6f9fa1'); data.append('redirect_uri', pbAuthHost); data.append('code_verifier', localStorage.getItem('pb-state')); data.append('code', code); var xhr = new XMLHttpRequest(); xhr.open('POST', `${pbApiHost}/oauth/token`, true); xhr.onload = function () { // do something to response const result = JSON.parse(this.responseText); setCookie(`auth._token.pb`, 'Bearer ' + result['access_token'], 15); setCookie(`auth._refresh_token.pb`, result['refresh_token'], 15); loginWindow.close(); pbJq('#pbvcc-signup-container').hide(); pbVCC_reloadContainer() }; xhr.send(data); } }); const redirectUri = pbAuthHost const clientId = '9a6d0766-9534-43bd-84dc-8c575e6f9fa1' const responseType = 'code'; (async () => { var state = generateRandomString(); var challenge = await getChallenge(state); // Any code here will be executed after the books variable has the value. localStorage.setItem('pb-state', state) localStorage.setItem('pb-challenge', challenge) const redirectUrl = `${pbApiHost}/oauth/authorize?protocol=oauth2&client_id=${clientId}&redirect_uri=${redirectUri}&response_type=${responseType}&scope=&state=${state}&code_challenge=${challenge}&code_challenge_method=S256&flow=vcc&email=${email}` loginWindow = window.open(redirectUrl, 'popup', 'width=700,height=950'); })() } async function getChallenge(code_verifier) { return await pkceChallengeFromVerifier(code_verifier) } function generateRandomString() { var array = new Uint32Array(28); window.crypto.getRandomValues(array); return Array.from(array, dec => ('0' + dec.toString(16)).substr(-2)).join(''); } // Calculate the SHA256 hash of the input text. // Returns a promise that resolves to an ArrayBuffer function sha256(plain) { const encoder = new TextEncoder(); const data = encoder.encode(plain); return window.crypto.subtle.digest('SHA-256', data); } // Base64-urlencodes the input string function base64urlencode(str) { // Convert the ArrayBuffer to string using Uint8 array to conver to what btoa accepts. // btoa accepts chars only within ascii 0-255 and base64 encodes them. // Then convert the base64 encoded to base64url encoded // (replace + with -, replace / with _, trim trailing =) return btoa(String.fromCharCode.apply(null, new Uint8Array(str))) .replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, ''); } // Return the base64-urlencoded sha256 hash for the PKCE challenge async function pkceChallengeFromVerifier(v) { hashed = await sha256(v); return base64urlencode(hashed); } function pbVCC_loadCompanyTrustPage() { window.open(`${pbTrustHost}${slug}?aff=${token}`, '_blank'); } function pbVCC_loadVendorTrustPage(slug) { window.open(`${pbTrustHost}${slug}?aff=${token}`, '_blank'); } function pbVCC_submitEmail() { const email = pbJq('#pbvcc-email-input').val() const isValid = pbVCC_isEmail(email) if (!isValid) { pbJq('#pbvcc-email-invalid').show() return; } else { pbJq('#pbvcc-email-invalid').hide() } pbVCC_Login(email) } function pbVCC_closePanel() { pbVccContainer.hide(); } function pbVCC_closeSignupPanel() { pbJq('#pbvcc-signup-container').hide(); } function pbVCC_setLoggedInDisplay(username) { pbJq('.vcc-logged-in').empty().text(username); } function pbVCC_socialLogin(who) { window.addEventListener('message', (event) => { pbVCC_reloadContainer() }); const signup = window.open(`${pbApiHost}/login?flow=vcc&provider=${who}`, "",'width=700,height=800') } function pbVCC_isEmail(email) { var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; return regex.test(email); } function pbVCC_populateCompany() { name = allData.company_name url = allData.company_domain logo = allData.company_logo token = allData.company_token slug = allData.company_slug pbVccContainer.find('#pbvcc-company-logo img').attr("src", logo) pbVccContainer.find('#pbvcc-company-name').text(name) pbVccContainer.find('#pbvcc-company-url').text(url) pbVccContainer.find('#pbvcc-company-name').text(name) } function pbVCC_showInfo() { pbVccContainer.hide(); const help = pbJq(showHelp); help.find('#pbvcc-help-company').text(name) pbJq('body').append(help); help.show(); } function pbVCC_hideInfo() { pbJq('#pbvcc-show-help-container').remove(); pbVccContainer.show(); } function setCookie(name,value,days) { var expires = ""; if (days) { var date = new Date(); date.setTime(date.getTime() + (days*24*60*60*1000)); expires = "; expires=" + date.toUTCString(); } console.log(name + "=" + (value || "") + expires + "; path=/;domain=" + allData['domain']) document.cookie = name + "=" + (value || "") + expires + "; path=/;domain=" + allData['domain']; } function getCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'; } function pbVCC_runCustomerSetup() { pbVCC_populateCompany() }