var loadPrivacy = function() { var titleId = ["DBS – Enquiry", "DBS - Complaint", "DBS - New Registration", "DBS - New Organization Registration"].indexOf(document.title) if (titleId == -1) return false; var documentTitle = document.getElementById("pt1:r1:0:ol1") if (documentTitle == null) //something's wrong, we don't have a title return false; var languageFlag = 0 // english if (document.getElementById("pt1:pt_pgl14").children[0].innerText == "Ymddangos ar ei gorau mewn crôm .") languageFlag = 1 // welsh // verify current loaded page var pageId = [["Enquiry", "Complaint", "Create a new individual online account", "Create a new organisation online account"], ["Ymholiad", "Cwyn", "Creu cyfrif ar-lein newydd ar gyfer unigolyn", "Creu cyfrif ar-lein newydd ar gyfer sefydliad"] ][languageFlag].indexOf(documentTitle.innerText) if (pageId != titleId) return false; var privacyDiv = document.getElementById("privacyDiv") if (privacyDiv != null && privacyDiv.offsetParent !== null) // the current div is visible return false else if (privacyDiv != null) // it is not visible but exists, so we need to remove it before proceeding privacyDiv.remove() console.log("inserting privacy consent checkbox") var normalisedPageId = pageId >> 1 var infoboxText = [ [ "I have read and understood the Disclosure and Barring Service Online Services and Enquiry Matrix Privacy Policy.", "Rwyf wedi darllen a deall Polisi Preifatrwydd Gwasanaethau Ar-lein a Matrics Ymholiadau y Gwasanaeth Datgelu a Gwahardd (DBS)."], [ "I have read and understood the Disclosure and Barring Service Online Account Privacy Policy.", "Rwyf wedi darllen a deall Polisi Preifatrwydd Cyfrif Porth y Gwasanaeth Datgelu a Gwahardd (DBS)."] ][normalisedPageId][languageFlag] var labelLinkText = [ [ "Disclosure and Barring Service Online Services and Enquiry Matrix Privacy Policy", "Polisi Preifatrwydd Gwasanaethau Ar-lein a Matrics Ymholiadau y Gwasanaeth Datgelu a Gwahardd (DBS)"], [ "Disclosure and Barring Service Online Account Privacy Policy", "Polisi Preifatrwydd Cyfrif Ar-lein y Gwasanaeth Datgelu a Gwahardd (DBS)"] ][normalisedPageId][languageFlag] var labelLinkLink = [ [ "https://www.gov.uk/government/publications/online-services-and-enquiry-matrix-privacy-policy", "https://www.gov.uk/government/publications/online-services-and-enquiry-matrix-privacy-policy/polisi-preifatrwydd-gwasanaethau-ar-lein-a-matrics-ymholiadau"], [ "https://www.gov.uk/government/publications/online-account-privacy-policy", "https://www.gov.uk/government/publications/online-account-privacy-policy/polisi-preifatrwydd-cyfrif-ar-lein-gwasanaeth-datgelu-a-gwahardd"] ][normalisedPageId][languageFlag] //the disclaimer label var labelLink = document.createElement("a") labelLink.innerText = labelLinkText labelLink.setAttribute("href", labelLinkLink) var labelDiv = document.createElement("div") labelDiv.append(infoboxText, document.createElement("br"), document.createElement("br"), labelLink) //ADF table layout + checkbox var parentDiv = document.createElement("div") parentDiv.id = "privacyDiv" parentDiv.append(document.createRange().createContextualFragment('\u003Cdiv id="pt1:r1:0:pgl10" class="pglcontentReferralForm AFStretchWidth af_panelGroupLayout" style="border-color:Black; border-style:ridge; border-width:thin; "\u003E\u003Cdiv\u003E\u003Cimg id="pt1:r1:0:s36" src="/HomeOfficeExternalPortal/adf/images/t.gif" alt="" width="10" height="10"\u003E\u003C/div\u003E\u003Cdiv\u003E\u003Ctable cellpadding="0" cellspacing="0" border="0" summary="" id="pt1:r1:0:pgl20" class="pglcontentReferralForm af_panelGroupLayout"\u003E\u003Ctbody\u003E\u003Ctr\u003E\u003Ctd\u003E\u003Cimg id="pt1:r1:0:spacer20" src="/HomeOfficeExternalPortal/adf/images/t.gif" alt="" width="19" height="10"\u003E\u003C/td\u003E\u003Ctd\u003E\u003Cspan style="color:Red;"\u003E*\u003C/span\u003E\u003C/td\u003E\u003Ctd\u003E\u003Cimg id="pt1:r1:0:spacer21" src="/HomeOfficeExternalPortal/adf/images/t.gif" alt="" width="5" height="10"\u003E\u003C/td\u003E\u003Ctd\u003E\u003Cspan style="font-weight:bold; font-size:16.0px;" id="privacyInfoboxTitle"\u003E\u003C/span\u003E\u003C/td\u003E\u003C/tr\u003E\u003C/tbody\u003E\u003C/table\u003E\u003C/div\u003E\u003Cdiv\u003E\u003Chr id="pt1:r1:0:s20" class="af_separator"\u003E\u003C/div\u003E\u003Cdiv\u003E\u003Cdiv id="pt1:r1:0:pfl5" class="af_panelFormLayout"\u003E\u003Ctable cellpadding="0" cellspacing="0" border="0" summary="" style="width: auto"\u003E\u003Ctbody\u003E\u003Ctr\u003E\u003Ctd class="af_panelFormLayout_column" colspan="1"\u003E\u003Ctable cellpadding="0" cellspacing="0" border="0" width="100%" summary=""\u003E\u003Ctbody\u003E\u003Ctr\u003E\u003Ctd\u003E\u003C/td\u003E\u003Ctd\u003E\u003C/td\u003E\u003C/tr\u003E\u003Ctr\u003E\u003Ctd\u003E\u003C/td\u003E\u003Ctd class="af_panelFormLayout_content-cell"\u003E\u003Ctable cellpadding="0" cellspacing="0" border="0" summary="" id="pt1:r1:0:pgl14" class="pglcontentReferralForm af_panelGroupLayout"\u003E\u003Ctbody\u003E\u003Ctr\u003E\u003Ctd valign="top"\u003E\u003Ctable class="af_selectBooleanCheckbox" style="font-size:small;margin-right: -5px;" id="pt1:r1:0:sbc1" cellpadding="0" cellspacing="0" border="0" summary="" _adftrc="pt1:r1:0:sbc1::icon-style"\u003E\u003Ctbody\u003E\u003Ctr\u003E\u003Ctd class="af_selectBooleanCheckbox_label"\u003E\u003C/td\u003E\u003Ctd valign="top" nowrap="" class="AFContentCell"\u003E\u003Cspan class="af_selectBooleanCheckbox_content"\u003E\u003Cspan class="af_selectBooleanCheckbox_content-input"\u003E\u003Cinput id="privacyCheckbox" class="af_selectBooleanCheckbox_native-input" type="checkbox" onclick="this.focus()"\u003E\u003C/span\u003E\u003Clabel for="pt1:r1:0:sbc1::content" class="af_selectBooleanCheckbox_item-text"\u003E\u003C/label\u003E\u003C/span\u003E\u003C/td\u003E\u003C/tr\u003E\u003C/tbody\u003E\u003C/table\u003E\u003C/td\u003E\u003Ctd valign="top" id="privacyInfoboxContents"\u003E\u003C/td\u003E\u003C/tr\u003E\u003C/tbody\u003E\u003C/table\u003E\u003C/td\u003E\u003C/tr\u003E\u003C/tbody\u003E\u003C/table\u003E\u003C/td\u003E\u003C/tr\u003E\u003C/tbody\u003E\u003C/table\u003E\u003C/div\u003E\u003C/div\u003E\u003Cdiv\u003E\u003Cimg id="pt1:r1:0:s23" src="/HomeOfficeExternalPortal/adf/images/t.gif" alt="" width="9" height="10"\u003E\u003C/div\u003E\u003Cdiv\u003E\u003Cimg id="pt1:r1:0:spacer11" src="/HomeOfficeExternalPortal/adf/images/t.gif" alt="" width="6" height="11"\u003E\u003C/div\u003E\u003C/div\u003E')) parentDiv.querySelector("#privacyInfoboxContents").append(labelDiv) parentDiv.querySelector("#privacyInfoboxTitle").append(["Privacy Policy Consent", "Caniatâd Polisi Preifatrwydd"][languageFlag]) parentDiv.style.paddingTop = '40px' var checkbox = parentDiv.querySelector("#privacyCheckbox") // disable and hide the Submit button var submitId = ["pt1:r1:0:cb5510", "pt1:r1:0:cb1"][normalisedPageId] var submitButton = document.getElementById(submitId) var updateSubmitButton = function() { var submitButton = document.getElementById(submitId) if (checkbox.checked) { submitButton.removeAttribute("disabled") submitButton.classList.remove("disabledSubmitButton") } else { submitButton.setAttribute("disabled", "true") submitButton.classList.add("disabledSubmitButton") } } updateSubmitButton() new MutationObserver(function(mutations) { // changing the Complaint / Enquiry type rebuilds the Submit button updateSubmitButton() }).observe( document.getElementById("pt1:r1:0:pgl2"), {subtree: true, characterData: true, childList: true} ); checkbox.addEventListener("click", updateSubmitButton) document.getElementById(["pt1:r1:0:pgl8", "pt1:r1:0:pgl8", "pt1:r1:0:pgl15", "pt1:r1:0:pgl2"][pageId]).parentNode.after(parentDiv) }; var observer = new MutationObserver(function(mutations) { loadPrivacy() }) try { observer.observe( document.body, {subtree: true, characterData: true, childList: true} ); } catch {} // if we're already on the page, from an external link window.addEventListener("load", () => { observer.observe( document.body, {subtree: true, characterData: true, childList: true} ); loadPrivacy() }) //if we've navigated to it observer.observe( document.querySelector('title'), {subtree: true, characterData: true, childList: true} ); window.navigation.addEventListener("navigate", loadPrivacy) //new MutationObserver(function(mutations) { // if (document.getElementById("pt1:navmenu:0:cil2") != null && document.getElementById("pt1:navmenu:1:cil2") != null) { // document.getElementById("pt1:navmenu:0:cil2").addEventListener("click", loadPrivacy) // document.getElementById("pt1:navmenu:1:cil2").addEventListener("click", loadPrivacy) // } //}).observe( // document.getElementById('pt1:pg_account'), // {subtree: true, characterData: true, childList: true} // ); // if we changed languages observer.observe( document.querySelector('html'), {attributes: true, characterData: true} );