-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBlueCat Address Manager Table Counter.user.js
97 lines (95 loc) · 4.34 KB
/
BlueCat Address Manager Table Counter.user.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// ==UserScript==
// @name BlueCat Address Manager Table Counter
// @namespace *
// @description Add count of value Table in BlueCat Address Manager (no paging support)
// @include */app*
// @license MIT
// @version 5
// @grant none
// @copyright 2018, Marius Galm
// @license MIT
// @icon https://www.bluecatnetworks.com/wp-content/uploads/2018/03/cropped-bluecat-favicon-32x32.png
// ==/UserScript==
if (document.readyState === "interactive" ) {
var subtab = document.getElementsByClassName("TabPanelLabelActive")[0];
if (subtab !== undefined) {
if (/Details/.test(subtab.innerHTML.trim())) {
// skip Details Section because counting it broken there a.t.m.
} else {
countTables();
}
}
}
function countTables() {
//for dialog-hd
var dialogBars = document.getElementsByClassName('dialog-hd');
if (( dialogBars !== undefined ) || (dialogBars.length < 0)) {
//console.log(dialogBars.length);
if (dialogBars.length === 1) {
if ( dialogBars[0] !== undefined ) {
var idname = dialogBars[0].id;
var prefix = idname.split('-bar')[0];
var namepart = prefix.split('_');
var part = namepart[1];
var name = namepart[0];
var outertable;
if (part === undefined) {
//console.log("iterating through first "+name);
outertable = document.getElementById("outerTable");
} else {
part = "_"+part;
//console.log("iterating "+name+" with part "+part);
outertable = document.getElementById("outerTable"+part);
//console.log(outertable);
if ((outertable == null)||(outertable === undefined)) {
// fallback to no part query
//console.log("ahhh");
outertable = document.getElementById("outerTable");
//console.log(outertable);
}
}
if (outertable.getElementsByClassName("empty-table").length !== 1) {
var count = outertable.rows.length - 1;
var tBody = dialogBars[0].getElementsByTagName('tbody')[0];
var tR = tBody.getElementsByTagName('tr')[0];
var tD = tR.getElementsByTagName('td')[0];
var span = tR.getElementsByTagName('span')[0];
var node = document.createElement("span");
node.innerHTML='<span class="label"> <i>Count: '+count+'</i></span>';
span.appendChild(node);
//var x = tR.insertCell(2);
//x.innerHTML='<span class="label">Count: '+count+'</span>';
}
}
} else {
for (var i = 0; i < dialogBars.length; i++) {
//console.log(dialogBars[i]);
if ( dialogBars[i] !== undefined ) {
var idname = dialogBars[i].id;
var prefix = idname.split('-bar')[0];
var namepart = prefix.split('_');
var part = namepart[1];
var name = namepart[0];
var outertable;
if (part === undefined) {
//console.log("iterating through first "+name);
outertable = document.getElementById("outerTable");
} else {
part = "_"+part;
//console.log("iterating "+name+" with part "+part);
outertable = document.getElementById("outerTable"+part);
}
if (outertable.getElementsByClassName("empty-table").length !== 1) {
var count = outertable.rows.length - 1;
var tBody = dialogBars[i].getElementsByTagName('tbody')[0];
var tR = tBody.getElementsByTagName('tr')[1];
var w = tR.insertCell(-1);
w.innerHTML='<div class="separator"></div>';
var x = tR.insertCell(-1);
x.innerHTML='<span class="label"><i>Count: '+count+'</i></span>';
}
}
}
}
}
}