PageSourceSearch

http://www.psiadvisor.com/include/js/navigation/nav_surgeon.js

js psiadvisor.com collected 2026-09-26 05:36:34 UTC 1,971 bytes, 90 lines download raw bytes

1var navHospital = navHospital || (function(){
2
3	const bc = document.body.classList
4	let n = document.getElementById('navigationContainer')
5
6	function removeLinks(array){
7		if (!Array.isArray(array))
8			return false
9
10		let as = Array.from(n.querySelectorAll('a')),
11		filtered = as.filter(function(a){
12			let h = a.getAttribute('href')
13			if (h){
14				let _h = h.toLowerCase()
15				return array.some(function(l){return _h.includes(l)})
16			}
17		})
18
19		filtered.forEach(function(a){
20			let li = a.parentElement,
21			ul = li.parentElement,
22			_li = ul.parentElement,
23			_ul = _li.parentElement,
24		 	_a = _li.firstElementChild
25
26			if (li.tagName != 'LI')
27				return false
28
29			if (!li.querySelector('ul')){
30				li.remove()
31
32				if (ul.children.length === 0){
33					if (_li.tagName === 'LI' && _a.tagName === 'A'){
34						let h = _a.getAttribute('href')
35
36						if (h){
37							let _h = h.toLowerCase()
38
39							if (array.some(function(l){return _h.includes(l)}) || ['#','','javascript:void(0);'].some(function(l){return _h === l})){
40								_li.remove()
41
42								if(_ul.tagName === 'UL' && _ul.children.length === 0)
43									_ul.remove()
44
45								return false
46							}
47							else if (array.some(function(l){return _h.includes(l)})){
48								_a.href = '#'
49							}
50						}
51					}
52					ul.remove()
53				}
54			}
55			else{
56				a.href = '#'
57			}
58		})
59
60		let remaining = filtered.filter(function(a){return n.contains(a)})
61		if (remaining.length){
62			remaining.forEach(function(a){
63				let li = a.parentElement,
64				ul = a.nextElementSibling
65
66				if (!ul && li.tagName === 'LI')
67					li.remove()
68			})
69		}
70	}
71
72	function setNavigation(el){
73		if (!el instanceof HTMLElement)
74			return false
75
76		n = el
77	}
78
79	if (bc.contains('_245')){
80		const t3s = n.querySelectorAll('.nav_ul ul ul')
81		t3s.forEach(function(el){
82			el.remove()
83		})
84	}
85
86	return {
87		setNavigation:setNavigation,
88		removeLinks:removeLinks
89	}
90})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.