Javascript add random param to URL

Date: 2021-02-18
(() => {
	const removeHash = h => h.indexOf("#") < 0 ? h : h.slice(0, h.indexOf('#'));
	const randomParam = () => "_=" + String(Math.random()).slice(2);
	const addParam = u => u.indexOf("?") < 0 ? u + '?' + randomParam() : u + "&" + randomParam();

	const currentHref = window.location.href;
	const newHref = addParam(removeHash(currentHref)) + window.location.hash;
	window.location.href = newHref;
})();
46530cookie-checkJavascript add random param to URL