forked from seapals/avionte2020
-
Notifications
You must be signed in to change notification settings - Fork 0
/
alt.js
155 lines (130 loc) · 4.39 KB
/
alt.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
152
153
154
155
// Inject classes
function notFound(x){
console.log("no " + x + " found");
};
function injectClass(targetType, targetName, className) {
switch (targetType) {
case "id": {
const element = document.getElementById(targetName);
element != null ? element.classList.add(className) : notFound(targetName);
break;
}
case "class": {
const element = document.getElementsByClassName(targetName);
for (i = 0; i < element.length; i++) {
element != null ? element[i].classList.add(className) : notFound(targetName);
}
break;
}
case "tag": {
const element = document.getElementsByTagName(targetName);
for (i = 0; i < element.length; i++) {
element != null ? element[i].classList.add(className) : notFound(targetName);
}
break;
}
}
}
// Remove classes
function stripClass(targetType, targetName, className) {
switch (targetType) {
case "id": {
const element = document.getElementById(targetName);
element != null ? element.classList.remove(className) : notFound(targetName);
break;
}
case "class": {
const element = document.getElementsByClassName(targetName);
for (i = 0; i < element.length; i++) {
element != null ? element[i].classList.remove(className) : notFound(targetName);
}
break;
}
case "tag": {
const element = document.getElementsByTagName(targetName);
for (i = 0; i < element.length; i++) {
element != null ? element[i].classList.remove(className) : notFound(targetName);
}
break;
}
}
}
// Remove classes
function stripAttr(targetType, targetName, attrName) {
switch (targetType) {
case "id": {
const element = document.getElementById(targetName);
element != null ? element.removeAttribute(attrName) : notFound(targetName);
break;
}
case "class": {
const element = document.getElementsByClassName(targetName);
for (i = 0; i < element.length; i++) {
element != null ? element[i].removeAttribute(attrName) : notFound(targetName);
}
break;
}
case "tag": {
const element = document.getElementsByTagName(targetName);
for (i = 0; i < element.length; i++) {
element != null ? element[i].removeAttribute(attrName) : notFound(targetName);
}
break;
}
}
}
// Remove ID
function stripID(targetID) {
element = document.getElementById(targetID);
element.removeAttribute('id');
}
document.addEventListener("DOMContentLoaded", () => {
// Cleanup
/*
Main Layout
*/
/* Wrapper containers */
// Main content wrapping element - Needs regular container
injectClass("id", "mainContentAll", "container-md");
// Remove zoom:1 style from body
stripAttr("tag", "body", "style");
stripAttr("id", "ctl00__IG_CSS_LINKS_", "value");
// injectClass("id", "applicantCenter", "container-md");
/*
Layout blocks
*/
injectClass("id", "footer", "row");
// Layout containers
injectClass("tag", "table", "container-md");
stripClass("class", "igpnl_CaribbeanPanel", "igpnl_CaribbeanPanel");
// Make main form tables responsive
/* Tables */
injectClass("class", "table_normal", "table-grid");
stripClass("class", "table_normal", "table_normal");
injectClass("id", "ctl00_ContentPlaceHolder1_PersonalInfo1_WebPanel1_ContactMethodList1_GridView1", "table-grid");
stripAttr("class", "table_outer", "style");
stripAttr("tag", "table", "width");
stripAttr("tag", "table", "height");
stripAttr("tag", "table", "border");
stripAttr("tag", "table", "style");
stripAttr("tag", "table", "cellspacing");
stripAttr("tag", "table", "cellpadding");
stripAttr("tag", "td", "style");
stripAttr("tag", "td", "width");
stripAttr("tag", "td", "align");
stripAttr("tag", "td", "valign");
stripAttr("tag", "div", "style");
stripAttr("tag", "span", "style");
stripAttr("tag", "textarea", "style");
/* Inputs */
injectClass("tag", "select", "form-control");
injectClass("class", "answerboxType", "form-control");
injectClass("tag", "input", "form-control");
stripAttr("tag", "input", "style");
stripClass("class", "button", "form-control");
// stripClass("id", "ctl00$ContentPlaceHolder1$Button2", "form-control");
// stripClass("class", "button", "form-control");
// injectClass("class", "button", "btn");
// injectClass("class", "button", "btn-primary");
// stripClass("class", "button", "button");
});