-
Notifications
You must be signed in to change notification settings - Fork 0
/
DifferentiateFarms.js
152 lines (128 loc) · 4.41 KB
/
DifferentiateFarms.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// ==UserScript==
// @name Differentiate farms
// @namespace http://tampermonkey.net/
// @version 0.13
// @description Add some differentiation to farms!
// @author oesteban
// @updateURL https://raw.githubusercontent.com/oesteban-vx/Tampermonkey/main/DifferentiateFarms.js
// @downloadURL https://raw.githubusercontent.com/oesteban-vx/Tampermonkey/main/DifferentiateFarms.js
// @match http://*.elasticbeanstalk.com/*
// @match http://*.web.farm.vexcelgroup.com/*
// @include http://qy-farm-*
// @icon http://qy-farm-101:8080/resources/images/amsgeo_logo.ico
// @grant GM_addStyle
// ==/UserScript==
const stringHashCode = str => {
let hash = 0
for (let i = 0; i < str.length; ++i) {
hash = (Math.imul(31, hash) + str.charCodeAt(i)) | 0
}
return hash
}
var farm_abbrevs = {
"publishing" : ["pub", "ffe6b0"], // orange
"reproj" : ["rep1", "fff1b8"],
"reproj1" : ["rep1", "fff1b8"],
"reproj2" : ["rep2", "fff1e0"],
"reproj3" : ["rep3", "8bfbf0"], // blue
"reproj4" : ["rep4", "8bebfb"],
"idpsreproj" : ["i-rep", "e2f9d8"], // green
"indexing" : ["idx", "f2e99f"], // yellow
"auxiliary" : ["aux", "eed6d6"], // red
"qc" : ["qc", "fda3e6"], // pink
"dxm" : ["dxm", "cfd2d6"], // gray
};
(function() {
'use strict';
var host = location.hostname;
var hash = stringHashCode(host)
hash &= 0xffffff
hash |= 0xc0c0c0
var color = hash.toString(16)
var farm = ""
var regexes = [
// http://prodcloudweb-prod-indexing-ue1.us-east-1.elasticbeanstalk.com/tasks/show
// http://prodcloudweb-production-publishing-ue1.us-east-1.elasticbeanstalk.com/secured/workunits/workunit/n32w97-us-tx-fortworth-2020_n32w97-us-tx-fortworth-2020__PD_OGG/1090
// http://prodcloudweb-prod-citizen.us-west-2.elasticbeanstalk.com/tasks/show
/prodcloudweb-prod[^-]*-(.*?)[\.-]/,
// http://prodcloudweb-dev.us-west-2.elasticbeanstalk.com/tasks/show
/prodcloudweb-([^\.]+)/,
// http://reproj1.web.farm.vexcelgroup.com
/([^\.]+)\.web.farm.vexcelgroup.com/,
// http://qy-farm-001:8080
/(qy-farm-\d+)/,
]
for(var i = 0, size = regexes.length; i < size ; i++)
{
var r = regexes[i].exec(host)
if (r) {
farm = r[1]
var item = farm_abbrevs[farm]
if (item)
{
// alert("item 0 = " +item[0]);
farm = item[0]
if (item[1]) {
color = item[1]
}
}
break
}
}
if (farm == "")
{
var base_color = "80cfff" // darkish-blue
r = /qy-farm-(\d+)/.exec(host)
if (r)
{
var qy_number = parseInt(r[1], 10)
color = parseInt(base_color,16)
color += 0x00100 * qy_number / 100 * 10
color += 0x10000 * qy_number % 100 * 10
color = "#" + color.toString(16)
}
}
GM_addStyle("* { background-color: #" + color + "; } ");
GM.addStyle(".navbar-brand {font-size: 30px;}");
if (farm != "")
{
var title = ""
// .../secured/workunits/workunit/n35w84-us-tn-etowah-2019_SPHERICALORTHO_OGGWFI_OHLG/1
var WU = /\/workunits\/workunit\/(.*)\/(\d+)/.exec(location.href)
// .../tasks/task/n35w84-us-tn-etowah-2019_SPHERICALORTHO_OGGWFI_OHLG
var task = /\/tasks\/task\/(.*?)([?\/]|$)/.exec(location.href)
// .../tasks/task/n35w84-us-tn-etowah-2019_SPHERICALORTHO_OGGWFI_OHLG
var create_task = /\/tasks\/createTask/.exec(location.href)
// .../secured/clients/show
var others = /\/secured\/([^/]+)\//.exec(location.href)
if (WU)
{
title = WU[1] + " / " + WU[2]
}
else if (task)
{
title = task[1]
}
else if (others)
{
title = others[1]
}
else if (create_task)
{
title = "Create task"
}
else if (/loginPage/.exec(location.href))
{
title = "Login"
}
if (title != "")
{
title = title + " /"
}
document.title = title + farm
var elements = document.getElementsByClassName("navbar-brand");
if (elements) {
elements[0].text = farm.toUpperCase()
}
}
})();