/** * Office Monster – /register checkbox wording * - Rewords the T&Cs, newsletter and Monster Rewards checkboxes * - Links "Terms and Conditions" to /terms-conditions (new tab) * - Removes the "By checking the box above..." blurb under the T&Cs box * Only runs on /register – exits immediately on every other page. */ (function () { "use strict"; // Only run on the registration page (/register or /register/) if (!/^\/register\/?$/i.test(window.location.pathname)) return; var TERMS_URL = "/terms-conditions"; var LABELS = { termsandconditionscheck: function () { var frag = document.createDocumentFragment(); frag.appendChild( document.createTextNode("I have read and agree to the "), ); var a = document.createElement("a"); a.href = TERMS_URL; a.target = "_blank"; a.rel = "noopener"; a.textContent = "Terms and Conditions"; frag.appendChild(a); frag.appendChild(document.createTextNode(".*")); return frag; }, newsletter_status: "Email me exclusive offers and product recommendations.", rewards_status: "Join Monster Rewards and earn points on purchases.", }; function relabel(id, content) { var input = document.getElementById(id); if (!input) return; var label = input.closest("label"); if (!label || label.getAttribute("data-om-relabelled")) return; // Remove the existing text (text nodes only) – keep the input and the // .control__indicator div the custom checkbox styling depends on Array.prototype.slice.call(label.childNodes).forEach(function (node) { if (node.nodeType === 3) label.removeChild(node); }); var span = document.createElement("span"); span.className = "om-checkbox-text"; if (typeof content === "function") { span.appendChild(content()); } else { span.textContent = content; } input.insertAdjacentElement("afterend", span); label.setAttribute("data-om-relabelled", "1"); } function removeTermsBlurb() { var form = document.querySelector("form.register-form"); if (!form) return; var blurb = form.querySelector(".form-group.small"); if (blurb && /terms and conditions/i.test(blurb.textContent)) { blurb.parentNode.removeChild(blurb); } } function run() { if (!document.querySelector("form.register-form")) return; Object.keys(LABELS).forEach(function (id) { relabel(id, LABELS[id]); }); removeTermsBlurb(); } if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", run); } else { run(); } })();