Skip to content

Instantly share code, notes, and snippets.

@karimal
Last active April 15, 2019 11:26
Show Gist options
  • Save karimal/40040f855b4612bd32397edac67db50c to your computer and use it in GitHub Desktop.
Save karimal/40040f855b4612bd32397edac67db50c to your computer and use it in GitHub Desktop.
// Variation 1 > will show old banner
- JS
/* CUSTOM CODE */
var shouldShowBar = JSON.parse(localStorage.getItem('COOKIES_BAR__SHOW')) !== 'no' ;
if (shouldShowBar) {
setTimeout(function() {
document.getElementsByClassName('testCookiesBar')[0].remove();
var event = document.createEvent('Event');
event.initEvent('updateOffset', true, true);
document.dispatchEvent(event);
}, 100);
}
----------------------------------------------------------------------------------
// Variation 2 > will show new banner
- CSS
.originalCookiesBar {
display: none !important;
}
- JS
/* CUSTOM CODE */
var shouldShowBar = JSON.parse(localStorage.getItem('COOKIES_BAR__SHOW')) !== 'no' ;
if (shouldShowBar) {
setTimeout(function() {
document.getElementsByClassName('originalCookiesBar')[0].remove();
document.getElementsByClassName('testCookiesBar')[0].style.display = 'block';
var event = document.createEvent('Event');
event.initEvent('updateOffset', true, true);
document.dispatchEvent(event);
}, 100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment