-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBlueCat Address Manager Auto-Switch to Tagged Objects.user.js
61 lines (57 loc) · 2.28 KB
/
BlueCat Address Manager Auto-Switch to Tagged Objects.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
// ==UserScript==
// @name BlueCat Address Manager Auto-Switch to Tagged Objects
// @namespace *
// @description Automatically switch to Tagged Objects if no SubTags exist in BlueCat Address Manager
// @include */app*
// @exclude */app*sp=ScontextId%3Dtag
// @license MIT
// @version 4
// @grant none
// @copyright 2018, Marius Galm
// @license MIT
// @icon https://www.bluecatnetworks.com/wp-content/uploads/2018/03/cropped-bluecat-favicon-32x32.png
// ==/UserScript==
// give up after 5 tries = 2,5 sec
var k = 0, howManyTimes = 5;
function getNodes() {
var count = k+1;
console.log(" + looking for nodes "+count+"/"+howManyTimes);
var nodes = document.getElementsByClassName("TreeNode").length;
k++;
if(( k < howManyTimes )&&(nodes === 0)){
setTimeout( getNodes, 500 );
}
else if ((k === howManyTimes)&&(nodes === 0)) {
document.getElementById("contextTabLink_1").click();
} else {
//console.log("nothing to do");
return;
}
};
// Exclude Pattern will prevent endless loop :-)
if (document.readyState === "interactive" ) {
var page = document.childNodes[2].nodeValue;
if (/ Page: Tags /.test(page)) {
// check subtab, should only be executed on Tags not Tagged Objects
var subtab = document.getElementsByClassName("TabPanelLabelActive")[0];
if (subtab.innerText === "Tags") {
var info = document.getElementById("informal");
if ((info !== undefined)&&(info !== null)) {
//console.log("found informal table - assuming table view");
// Table View
if (document.getElementsByClassName("empty-table").length === 1) {
// empty -> switch to tagged objects
document.getElementById("contextTabLink_1").click();
}
} else {
//console.log("informal id not found or null - assuming tree view");
// checking nodes
if (document.getElementsByClassName("TreeNode").length === 0) {
getNodes();
//console.log(document.getElementsByClassName("TreeNode").length);
//document.getElementById("contextTabLink_1").click();
}
}
}
}
}