var omUnsubscribePart = { defaultUuid: '{form_uuid}', searchText: 'ccpa.lendyou.com', getURLParameterByName: function(name) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var regex = new RegExp("[\\?&]" + name + "=([^&#]*)", 'i'), results = regex.exec(location.search); return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, " ")); }, getCookieItemByName: function(key) { var matches = document.cookie.match(new RegExp('^(.*\; )?' + key + '=(.*?)(;|$)')); return matches === null ? '' : matches[2] || ''; }, checkUuid: function() { return (omUnsubscribePart.getURLParameterByName('uuid')) ? omUnsubscribePart.getURLParameterByName('uuid') : (omUnsubscribePart.getCookieItemByName('uuid')) ? omUnsubscribePart.getCookieItemByName('uuid') : omUnsubscribePart.defaultUuid; }, searchAllPageLinks: function() { return document.querySelectorAll('a[href*="' + omUnsubscribePart.searchText + '"]'); }, updateLinksAtPage: function() { var allNodes = omUnsubscribePart.searchAllPageLinks(); var uuid = omUnsubscribePart.checkUuid(); if (allNodes && typeof uuid === 'string' && uuid.length > 1) { Array.prototype.forEach.call(allNodes, function(link) { link.href += '&uuid=' + encodeURIComponent(uuid); }); } } }; window.addEventListener("load", function () { try { omUnsubscribePart.updateLinksAtPage(); } catch (e) { console.warn('Links not updated'); } });