-
Notifications
You must be signed in to change notification settings - Fork 1
/
hide_link_description.js
75 lines (67 loc) · 2.86 KB
/
hide_link_description.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// ==UserScript==
// @name ERPNext - Hide Extra Description in Multi Doctype
// @namespace http://tampermonkey.net/
// @version 1.2.5
// @description Hide extra data in item link suggestions
// @author H.P. Automotive
// @match https://erpnext.hpagroup.co.in/app/*
// @match https://hpa-group.frappe.cloud/app/*
// @grant none
// @updateURL https://raw.githubusercontent.com/hpautomotive/tampermonkey-hide_item_description_in_erpnext/main/hide_link_description.js
// @downloadURL https://raw.githubusercontent.com/hpautomotive/tampermonkey-hide_item_description_in_erpnext/main/hide_link_description.js
// ==/UserScript==
(function() {
'use strict';
/**
* Hide elements with specific classes and adjust layout
*/
function hideExtraData() {
try {
// Select all elements whose ID starts with 'awesomplete_list_'
const listBoxes = document.querySelectorAll('[id^="awesomplete_list_"]');
listBoxes.forEach(listBox => {
// Select and hide all span elements with the class 'small' within the matched elements
const smallElements = listBox.querySelectorAll('.small');
smallElements.forEach(element => {
element.style.display = 'none';
});
});
// Select and hide all div elements with the class 'col-xs-8' containing a span with the class 'text-muted'
const colElements = document.querySelectorAll('.col-xs-8');
colElements.forEach(colElement => {
const textMutedSpan = colElement.querySelector('.text-muted');
if (textMutedSpan) {
colElement.style.display = 'none';
}
});
// Adjust divs within link-select-row in popups
const linkRows = document.querySelectorAll('.row.link-select-row');
linkRows.forEach(linkRow => {
const col1 = linkRow.children[0];
const col2 = linkRow.children[1];
if (col2) {
col2.style.display = 'none';
col1.classList.replace('col-xs-4', 'col-xs-12');
}
});
} catch (error) {
console.error('Error in hideExtraData:', error);
}
}
/**
* Observe for changes in the DOM and apply the hiding logic
*/
function observeDOMChanges() {
const observer = new MutationObserver(mutations => {
hideExtraData();
});
observer.observe(document.body, {
childList: true,
subtree: true
});
// Initial call to hide elements in case they are already present
hideExtraData();
}
// Wait for the page to fully load before starting the observer
window.addEventListener('load', observeDOMChanges);
})();