The ad is also dismissable now! You can close it for the length of your browsing session
It will re-appear on new tabs and when you first open the site but will always be dismissable.
For some reason, the button is inert upon first site visit:
But on refresh/new tab it works:
Maybe DOMContentLoaded is an inappropriate event for the addEventListener (“DOMContentLoaded does not wait for stylesheets to load”)?
The DOMContentLoaded EventListener might be unnecessary since the ad is in the HTML at page load, so you can drop it altogether (but added a safety check in case either element is missing):
var _default = _exports.default = (0, _api.apiInitializer)(api => {
const ad = document.getElementById("custom-ad");
const dismissBtn = document.getElementById("dismiss-btn");
if (ad && dismissBtn) {
// if (sessionStorage.getItem("adDismissed")) {
// ad.style.display = "none";
// }
dismissBtn.addEventListener("click", function () {
ad.style.display = "none";
// sessionStorage.setItem("adDismissed", "true");
});
}
});