Set time to display reviews badge after closing again

We’d actually like the opposite to this, but still cookie related… when a user closes the reviews they dont show again for an extended period of time… can this timeframe be edited or changed? Or if the user visits the website again (by refreshing) can the reviews badge show again??

1 Like

Hi there @WUM :wave:

Great news - we have a solution:

const TIMEOUT = 5000;

const waitForElem = (selector) =>
	new Promise((resolve) => {
		if (document.querySelector(selector)) {
			return resolve(document.querySelector(selector));
		}

		const observer = new MutationObserver(() => {
			if (document.querySelector(selector)) {
				observer.disconnect();
				resolve(document.querySelector(selector));
			}
		});

		observer.observe(document.body, {
			childList: true,
			subtree: true,
		});
	});

waitForElem('.es-close-button').then((closeBtn) => {
	closeBtn.addEventListener('click', (e) => {
		e.stopImmediatePropagation();
		
		const badge = e.target?.closest('.es-badge-container');
		if (!badge) {
			return;
		}
        badge.style.display = 'none';
		setTimeout(() => {
			badge.style.display = 'inline-flex';
		}, TIMEOUT);
	});
});

This code should be added to the Custom JS field on the Settings tab of your widget’s settings.

In the 1st line of the code (TIMEOUT), you can set the time interval (in milliseconds) after which the badge should appear again. When refreshing the page, the badge will appear immediately.

Try it out and let me know how it worked :wink:

1 Like

Ohh thats fabulous! We’ll give it and try and see how we go. Thank you for the quick reply and resolution.

2 Likes