Skip to content

Instantly share code, notes, and snippets.

@jackm
Last active November 13, 2018 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackm/ce9aadcad9bbae6df48b0818b7af3fe8 to your computer and use it in GitHub Desktop.
Save jackm/ce9aadcad9bbae6df48b0818b7af3fe8 to your computer and use it in GitHub Desktop.
Greasemonkey/Tampermonkey userscript for various interface improvements to Unit4
// ==UserScript==
// @name Unit4 interface improvements
// @namespace https://ubw.unit4cloud.com
// @version 0.3
// @description Make the Unit4 interface more user friendly and less painful to enter information
// @match https://ubw.unit4cloud.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// "Requisitions - standard" Unit4 tab
var sections = document.querySelectorAll('div.u4-section-placeholder div.SectionControl.u4-section');
for (let i = 0; i < sections.length; i++) {
// Add more rows to the "Message" textarea
var taMsg = sections[i].querySelector('textarea[id$="_description_i"]');
if (taMsg) taMsg.rows = 10;
// Reduce rows of the "Delivery address" textarea
var taDa = sections[i].querySelector('textarea[id$="_deliv_addr_i"]');
if (taDa) taDa.rows = 1;
// Array of substrings for delivery addresses to keep; all others will be removed
var deliveryAddresses = [
"X11001",
"X11234"
];
// Search through the full list of delivery addresses (there are over 7700 of them...wtf) and remove the ones that do not contain the strings we want
// This makes loading the dropdown list and selecting an address MUCH faster
var deliveryAddrItems = sections[i].querySelectorAll('div.HiddenDiv xml[id$="_ctl00_77_XmlIsland"] list item');
for (let j = 0; j < deliveryAddrItems.length; j++) {
var tc = deliveryAddrItems[j].getElementsByTagName("DESCR")[0].textContent;
if (! deliveryAddresses.some(x => tc.includes(x)) )
deliveryAddrItems[j].remove();
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment