Last active
September 9, 2026 13:25
-
-
Save timwright12/3c92acbc742e2e4a4e4f74c89654279d to your computer and use it in GitHub Desktop.
overrideFeedbackWidgetDisclaimerText.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| This script can either be added into HTML between <script> tags or put in an external JS file | |
| */ | |
| // Utility function to wait for the element to appear in the DOM | |
| function waitForElement(selector, callback, timeout) { | |
| var startTime = new Date().getTime(); | |
| var interval = setInterval(function() { | |
| var element = document.querySelector(selector); | |
| // If element is found, clear interval and trigger callback | |
| if (element) { | |
| clearInterval(interval); | |
| callback(null, element); | |
| return; | |
| } | |
| // If timeout is reached, clear interval and trigger error | |
| if (timeout && (new Date().getTime() - startTime > timeout)) { | |
| clearInterval(interval); | |
| callback(new Error("Element " + selector + " not found within " + timeout + "ms")); | |
| } | |
| }, 100); // Checks every 100ms | |
| } | |
| // Utility function to reach into the DOM and override specific content | |
| function overrideFeedbackWidgetDisclaimerText(obj) { | |
| waitForElement(obj.element, function(error, element) { | |
| if (error) { | |
| console.error(error.message); | |
| return; | |
| } | |
| element.innerHTML = obj.content; | |
| }, 5000); // 5 second timeout | |
| } | |
| // Calling the function with an element target and the HTML you want to use | |
| overrideFeedbackWidgetDisclaimerText({ | |
| element: '#commentForm .disclaimer-text', | |
| content: 'Your feedback helps improve this web page. For specific questions about services or programs, contact the Division of Disability Services through our <a href="https://iqconnect.lmhostediq.com/iqextranet/EForm.aspx?__cid=NJDDS&__fid=100005" target="_blank" rel="noopener" aria-label="contact form (opens in new window)">contact form</a> or by calling <a href="tel:+1-888-285-3036">1-888-285-3036</a>.' | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment