From a793a7ec54b6747b9dd53722636ccb12eb658bee Mon Sep 17 00:00:00 2001 From: Derek Date: Sun, 15 Jun 2025 20:23:42 -0500 Subject: [PATCH] Updated Injecting code to UT Pages (markdown) --- Injecting-code-to-UT-Pages.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Injecting-code-to-UT-Pages.md b/Injecting-code-to-UT-Pages.md index c708d05..b83c5d5 100644 --- a/Injecting-code-to-UT-Pages.md +++ b/Injecting-code-to-UT-Pages.md @@ -46,6 +46,33 @@ if (support === SiteSupport.COURSE_CATALOG_SEARCH) { } ``` +# Erasing elements on webpages + +This can be accomplished easily through retrieving elements, for example using `document.getElementById`, and changing their `innerHTML` to `''` + +For example with DaysCheckbox + +```ts + const daysDropdown = document.getElementById('mtg_days_st') as HTMLSelectElement | null; + if (!daysDropdown) { + console.error('Days dropdown not found'); + return; + } + + const formElement = daysDropdown.closest('.form_element')!; + const checkboxContainer = document.createElement('div'); + + // Create a hidden input to store the value + const hiddenInput = document.createElement('input'); + hiddenInput.type = 'hidden'; + hiddenInput.name = 'mtg_days_st'; + hiddenInput.id = 'mtg_days_st_hidden'; + hiddenInput.value = daysDropdown.value; + + // Remove old dropdown + formElement.innerHTML = ''; +``` + # Examples ## CourseCatalogMain