-
Notifications
You must be signed in to change notification settings - Fork 0
/
content_old.js
1150 lines (993 loc) · 37.8 KB
/
content_old.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
var writeLog = false;
var companyName = "";
var url = (window.location.href);
const emptyTableResponse = "<thead><tr></tr></thead><tbody></tbody>";
const failMessage = " did NOT file H-1B in last couple of years.";
const successMessage = " did file H-1B in last couple of years.";
const LinkedIn = 'linkedin';
const LinkedInCompanyNames = ["job-card-container__link job-card-container__company-name ember-view", "job-card-container__primary-description", "job-card-container__company-name", "result-card__subtitle-link job-result-card__subtitle-link"];
const LinkedInSelectedCompanyName = '.job-details-jobs-unified-top-card__primary-description';
const Glassdoor = 'glassdoor';
const GlassdoorCompanyNames = ["css-8wag7x", "job-search-8wag7x"]; //"jobInfoItem jobTitle"; // css-10l5u4p e1n63ojh0 jobLink
//const GlassdoorSelectedCompanyName = ; // feature not there
const HandShake = 'handshake';
const HandShakeCompanyNames = ["style__job-detail___NfvjZ"]; //"jobInfoItem jobTitle"; // css-10l5u4p e1n63ojh0 jobLink
const Indeed = 'indeed';
const IndeedComapnyNames = "companyName";
const Simplify = 'simplify';
const SimplifyJobsName = ""
const Google = 'google';
const googleCompanyNames = ["vNEEBe"]
const GoogleSelectedCompanyName = "nJlQNd sMzDkb";
// if (url.includes(LinkedIn)) {
// createFloatingButton();
// /*initiate the autocomplete function on the "myInput" element, and pass along the countries array as possible autocomplete values:*/
// autocomplete(document.getElementById("h1bSearchInput"));
// }
//#region Float Button
function createFloatingButton() {
// const container = document.createElement("div");
// container.id = "autocomplete-container";
// const form = document.createElement("form");
// form.autocomplete = "off";
const searchContainer = document.createElement("div");
searchContainer.classList.add("search");
// const input = document.createElement("input");
// input.id = "h1bSearchInput";
// input.type = "text";
// input.name = "h1bSearchBox";
// input.placeholder = "Atleast 4 letters...";
const input = document.createElement("input");
input.id = "h1bSearchInput";
input.type = "search";
input.classList.add("search-box");
input.placeholder = "Atleast 4 letters...";
// const searchButton = document.createElement("input");
// searchButton.id = "h1bSearchBtn"
// searchButton.type = "button";
// searchButton.value = "Search";
const searchButton = document.createElement("span");
searchButton.classList.add("search-button");
const searchIcon = document.createElement("span");
searchIcon.classList.add("search-icon");
searchButton.appendChild(searchIcon);
searchButton.addEventListener("click", () => {
searchButton.parentElement.classList.toggle('open');
// Show the text box and search button
if (input.value.length > 3) {
chrome.runtime.sendMessage({
companyName: input.value, mode: "single"
}, function (response) {
console.log(response);
showResult(response);
//if (url.includes(Glassdoor)) {
var el = document.getElementsByName("hb_resultable");
el[0].innerHTML = response;
var modal = document.getElementById("myModal");
modal.style.display = "block";
//}
});
}
});
// form.appendChild(input);
// form.appendChild(searchButton);
// container.appendChild(form);
const spanText = document.createElement("span");
spanText.innerText = "Search H1b Employers";
searchContainer.appendChild(input);
searchContainer.appendChild(searchButton);
searchContainer.appendChild(spanText);
document.body.appendChild(searchContainer);
//document.body.appendChild(container);
//////////////////////////
// const searchContainer1 = document.createElement("div");
// searchContainer1.classList.add("search");
// const searchInput1 = document.createElement("input");
// searchInput1.type = "search";
// searchInput1.classList.add("search-box");
// const searchButton1 = document.createElement("span");
// searchButton1.classList.add("search-button");
// const searchIcon1 = document.createElement("span");
// searchIcon1.classList.add("search-icon");
// searchButton1.appendChild(searchIcon1);
// searchContainer1.appendChild(searchInput1);
// searchContainer1.appendChild(searchButton1);
// document.body.appendChild(searchContainer1);
// autocomplete(searchInput1);
}
//#endregion
//#region AutoComplete
function autocomplete(inp) {
/*the autocomplete function takes two arguments,
the text field element and an array of possible autocompleted values:*/
var currentFocus;
/*execute a function when someone writes in the text field:*/
inp.addEventListener("input", function (e) {
var a, b, i, val = this.value;
if (val.length < 5) return;
chrome.runtime.sendMessage({
companyName: val, mode: "search"
}, function (response) {
if (writeLog) console.log(response);
const arr = response;
/*close any already open lists of autocompleted values*/
closeAllLists();
if (!val) {
return false;
}
currentFocus = -1;
/*create a DIV element that will contain the items (values):*/
a = document.createElement("DIV");
a.setAttribute("id", inp.id + "autocomplete-list");
a.setAttribute("class", "autocomplete-items");
/*append the DIV element as a child of the autocomplete container:*/
inp.parentNode.appendChild(a);
/*for each item in the array...*/
for (i = 0; i < arr.length; i++) {
/*check if the item starts with the same letters as the text field value:*/
if (arr[i].substr(0, val.length).toUpperCase() == val.toUpperCase()) {
/*create a DIV element for each matching element:*/
b = document.createElement("DIV");
/*make the matching letters bold:*/
b.innerHTML = "<strong>" + arr[i].substr(0, val.length) + "</strong>";
b.innerHTML += arr[i].substr(val.length);
/*insert a input field that will hold the current array item's value:*/
b.innerHTML += "<input type='hidden' value='" + arr[i] + "'>";
/*execute a function when someone clicks on the item value (DIV element):*/
b.addEventListener("click", function (e) {
/*insert the value for the autocomplete text field:*/
inp.value = this.getElementsByTagName("input")[0].value;
/*close the list of autocompleted values,
(or any other open lists of autocompleted values:*/
closeAllLists();
});
a.appendChild(b);
}
}
});
});
/*execute a function presses a key on the keyboard:*/
inp.addEventListener("keydown", function (e) {
var x = document.getElementById(this.id + "autocomplete-list");
if (x) x = x.getElementsByTagName("div");
if (e.keyCode == 40) {
/*If the arrow DOWN key is pressed,
increase the currentFocus variable:*/
currentFocus++;
/*and and make the current item more visible:*/
addActive(x);
} else if (e.keyCode == 38) { //up
/*If the arrow UP key is pressed,
decrease the currentFocus variable:*/
currentFocus--;
/*and and make the current item more visible:*/
addActive(x);
} else if (e.keyCode == 13) {
/*If the ENTER key is pressed, prevent the form from being submitted,*/
e.preventDefault();
if (currentFocus > -1) {
/*and simulate a click on the "active" item:*/
if (x) x[currentFocus].click();
}
}
});
function addActive(x) {
/*a function to classify an item as "active":*/
if (!x) return false;
/*start by removing the "active" class on all items:*/
removeActive(x);
if (currentFocus >= x.length) currentFocus = 0;
if (currentFocus < 0) currentFocus = (x.length - 1);
/*add class "autocomplete-active":*/
x[currentFocus].classList.add("autocomplete-active");
}
function removeActive(x) {
/*a function to remove the "active" class from all autocomplete items:*/
for (var i = 0; i < x.length; i++) {
x[i].classList.remove("autocomplete-active");
}
}
function closeAllLists(elmnt) {
/*close all autocomplete lists in the document,
except the one passed as an argument:*/
var x = document.getElementsByClassName("autocomplete-items");
for (var i = 0; i < x.length; i++) {
if (elmnt != x[i] && elmnt != inp) {
x[i].parentNode.removeChild(x[i]);
}
}
}
/*execute a function when someone clicks in the document:*/
document.addEventListener("click", function (e) {
closeAllLists(e.target);
});
}
//#endregion
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
if (writeLog) console.log(request.message)
if (request.message === 'TabUpdated') {
if (writeLog) console.log(document.location.href);
setTimeout(function () {
removeOldElements();
process();
getDataForCompanies();
}, 800);
}
})
var pageLoaded = false;
var tryCount = 0;
setTimeout(function () {
try {
initiate();
pageLoaded = true;
} catch (error) {
pageLoaded = false;
tryCount = tryCount + 1;
while (pageLoaded === false && tryCount <= 5) {
setTimeout(function () {
initiate();
pageLoaded = true;
}, 1000);
}
}
}, 1000);
function initiate() {
if (document.location.href.includes(Glassdoor)) {
} else if (document.location.href.includes(LinkedIn)) {
} else if (document.location.href.includes(Indeed)) {
} else if (document.location.href.includes(HandShake)) {
}
}
function process() {
if (document.getElementsByName("hb_resultP").length > 0) {
return;
}
removeOldElements();
getCompanyName();
console.log(companyName);
if (companyName === undefined || companyName == "" || companyName == null) {
console.log("Cannot Find Company Name")
return;
}
if (!url.includes(Glassdoor)) {
getData();
}
}
function removeOldElements() {
if (document.getElementsByName("hb_resultable").length > 0) {
var elem = document.getElementsByName("hb_resultable")
for (var i = 0; i <= elem.length; i++) {
if (elem[i]) elem[i].remove();
}
}
if (document.getElementsByName("hb_resultP").length > 0) {
var elem = document.getElementsByName("hb_resultP")
for (var i = 0; i <= elem.length; i++) {
elem[i].remove();
}
}
if (document.getElementsByName("myBtn").length > 0) {
var elem = document.getElementsByName("myBtn")
for (var i = 0; i <= elem.length; i++) {
elem[i].remove();
}
}
if (document.getElementsByName("myModal").length > 0) {
var elem = document.getElementsByName("myModal")
for (var i = 0; i <= elem.length; i++) {
if (elem[i]) elem[i].remove();
}
}
}
function getCompanyName() {
try {
var try1 = '';
var try2 = '';
if (url.includes(Google)) {
const employerName = document.getElementsByClassName(GoogleSelectedCompanyName);
if (employerName) {
companyName = employerName.textContent;
return;
}
}
if (url.includes(HandShake)) {
try1 = "style__employer-name___54lqg";
let z1 = document.getElementsByClassName(try1);
if (z1.length > 0) {
companyName = z1[0].childNodes[0].textContent;
}
}
if (url.includes(Glassdoor)) {
const employerName = document.querySelector('[data-test="employerName"]');
if (employerName) {
companyName = employerName.textContent;
return;
}
// try1 = "employerName";
try1 = "css-l2wjgv e1n63ojh0 jobLink";
try2 = "jobs-details-top-card__company-url";
var z1 = document.getElementsByClassName(try1)
var z2 = document.getElementsByClassName(try2)
if (z1.length > 0) {
if (writeLog) console.log(z1)
companyName = z1[0].childNodes[0].textContent;
} else if (z2.length > 0) {
if (writeLog) console.log(z2)
companyName = z2[0].innerText;
}
} else if (url.includes(LinkedIn)) {
try1 = "topcard__org-name-link";
try2 = "jobs-details-top-card__company-url";
try3 = "ember-view t-black t-normal";
var z1 = document.getElementsByClassName(try1)
var z2 = document.getElementsByClassName(try2)
var z3 = document.getElementsByClassName(try3)
if (z1.length > 0) {
if (writeLog) console.log(z1)
companyName = z1[0].innerText;
} else if (z2.length > 0) {
if (writeLog) console.log(z2)
companyName = z2[0].innerText;
} else if (z3.length > 0) {
if (writeLog) console.log(z3)
companyName = z3[0].innerText;
} else {
//let element = document.querySelector('.jobs-unified-top-card__primary-description');
let element = document.querySelector(LinkedInSelectedCompanyName);
const companyNameElement = element.querySelector('div > a');
if (companyNameElement) companyName = companyNameElement.textContent;
//companyName = element.querySelector('a').textContent;
}
} else if (url.includes(Indeed)) {
const element = document.querySelector('div[data-company-name="true"] a');
if (element) {
companyName = element.textContent;
console.log(companyName);
return;
} else {
// Get the iframe element
var iframe = document.getElementById('vjs-container-iframe');
// Get the content window of the iframe
var iframeWindow = iframe.contentWindow;
// Use document.querySelector() to select elements inside the iframe
var link = iframeWindow.document.querySelector('div[data-company-name="true"] a');
if (link) {
if (link.childNodes.length > 1) {
companyName = link.childNodes[0].textContent;
} else {
companyName = link.textContent;
}
console.error(companyName);
return;
}
}
var iframeDocuemnt = document.getElementById("vjs-container-iframe");
if (iframeDocuemnt == null) {
var i1 = document.getElementsByClassName("jobsearch-InlineCompanyRating-companyHeader");
if (i1.length > 0) {
companyName = i1[1].childNodes[0].text;
return;
} else return;
}
try1 = "jobsearch-InlineCompanyRating";
try2 = "icl-u-lg-mr--sm icl-u-xs-mr--xs";
var z1 = iframeDocuemnt.contentWindow.document.body.getElementsByClassName(try1)
var z2 = iframeDocuemnt.contentWindow.document.body.getElementsByClassName(try2)
if (z1.length > 0) {
if (writeLog) console.log(z1)
companyName = z1[0].childNodes[1].innerText;
}
if (companyName == '' && z2.length > 0) {
if (writeLog) console.log(z2)
for (let index = 0; index < z2.length; index++) {
const element = z2[index].innerText;
if (element != '') {
companyName = z2[index].innerText;
return;
}
}
}
}
} catch (error) {
console.log(error)
}
}
function getData() {
chrome.runtime.sendMessage({
companyName: companyName, mode: "single"
}, function (response) {
if (writeLog) console.log(response);
showResult(response);
if (url.includes(Glassdoor)) {
var modal = document.getElementById("myModal");
modal.style.display = "block";
}
});
}
const createPElement = (status) => {
let color = '';
const iframeDocument = document.getElementById("vjs-container-iframe");
if (iframeDocument) {
const z1 = iframeDocument.contentWindow.document.body.getElementsByClassName("hb_resultP");
if (z1.length > 0) {
iframeDocument.contentWindow.document.body.getElementsByClassName("hb_resultP")[0].remove();
}
}
if (document.getElementsByName("hb_resultP").length > 0) {
const elList = document.getElementsByName("hb_resultP");
elList.forEach(element => {
element.remove();
});
}
const resultP = document.createElement("p");
resultP.setAttribute("name", "hb_resultP");
resultP.setAttribute("class", "hb_resultP");
if (status === 'success') {
color = 'green';
//btn
var btn = document.createElement("a");
btn.setAttribute("id", "myBtn");
btn.setAttribute("name", "myBtn");
btn.setAttribute("class", "myBtn");
btn.innerText = "H1b Info"
btn.addEventListener("click", () => {
removeOldElements()
var modal = "";
if (url.includes(Indeed)) {
modal = getIndeedModal()
} else {
modal = document.getElementById("myModal");
}
getData()
modal.style.display = "block";
});
// if (url.includes(Indeed)) {
// resultP.insertAdjacentElement('afterend', btn);
// } else {
// resultP.appendChild(btn);
// }
resultP.innerHTML = `${this.companyName}${successMessage} ${btn.outerHTML}`;
} else {
color = 'red';
resultP.innerHTML = `${this.companyName}${failMessage}`;
}
resultP.style = `color: ${color}`;
return resultP;
};
const getIndeedModal = () => {
const iframeDocument = document.getElementById("vjs-container-iframe");
if (iframeDocument) {
const z1 = iframeDocument.contentWindow.document.body.getElementsByClassName("h1bmodal");
return z1[0];
} else {
//const modal = document.getElementById("myModal");
const modal = document.getElementsByClassName("h1bmodal");
return modal;
}
};
function showResult(response) {
var noLoginDiv = "";
var loginDiv = "";
var jobCardDiv = "";
var el = document.getElementsByName("hb_resultable");
if (el && el.length > 0) el[0].innerHTML = response;
if (url.includes(Glassdoor)) {
//result table
return;
//jobCardDiv = document.querySelectorAll(`[data-test="employerName"]`);
//noLoginDiv = "css-1h9mu8x e14vl8nk0";
//noLoginDiv = "empInfo newDetails";
//loginDiv = "jobs-details-top-card";
} else if (url.includes(LinkedIn)) {
noLoginDiv = "topcard__flavor-row";// "topcard__content-left";
loginDiv = "ember-view t-black t-normal";
} else if (url.includes(Indeed)) {
const element = document.querySelector('div[data-company-name="true"] a');
if (element) {
jobCardDiv = element;
} else {
var iframeDocuemnt = document.getElementById("vjs-container-iframe");
if (iframeDocuemnt != null) {
var linkElement = iframeDocuemnt.contentWindow.document.querySelector('div[data-company-name="true"] a');
if (linkElement) {
jobCardDiv = linkElement;
} else {
try1 = "jobsearch-InlineCompanyRating";
try2 = "icl-u-lg-mr--sm icl-u-xs-mr--xs";
var z1 = iframeDocuemnt.contentWindow.document.body.getElementsByClassName(try1)
var z2 = iframeDocuemnt.contentWindow.document.body.getElementsByClassName(try2)
// console.log(z1)
// console.log(z2)
jobCardDiv = z1;
}
} else {
var i1 = document.getElementsByClassName("jobsearch-InlineCompanyRating-companyHeader");
if (i1.length > 0) {
jobCardDiv = i1[1];
} else console.log("No Div to attach.")
}
}
}
if (!url.includes(Indeed) && !url.includes(Glassdoor)) {
jobCardDiv = document.getElementsByClassName(noLoginDiv);
}
var divToAttach = "";
if (jobCardDiv.length == 0) {
jobCardDiv = document.getElementsByClassName(loginDiv);
}
if (url.includes(LinkedIn)) {
jobCardDiv = document.querySelector(LinkedInSelectedCompanyName);
}
if (jobCardDiv.length == 0) {
return;
}
if (writeLog) console.log(jobCardDiv)
if (url.includes(LinkedIn)) divToAttach = jobCardDiv; else if (url.includes(Glassdoor)) divToAttach = jobCardDiv[0].parentElement; else if (url.includes(Glassdoor)) divToAttach = jobCardDiv[0].parentElement.parentElement; else if (url.includes(Indeed)) {
if (jobCardDiv.length > 0) {
divToAttach = jobCardDiv[0];
} else {
divToAttach = jobCardDiv;
}
}
if (response === emptyTableResponse || response === null || response === undefined) {
var resultP = createPElement('fail');
// Check if the element with name "hb_resultP" already exists in the parent element
var existingElement = divToAttach.querySelector('p[name="hb_resultP"]');
if (existingElement) {
existingElement.remove();
}
divToAttach.appendChild(resultP);
return;
}
var resultP = createPElement('success');
if (url.includes(Indeed)) {
divToAttach.parentElement.insertAdjacentElement('afterend', resultP);
} else {
divToAttach.appendChild(resultP);
}
//result table
var resultTable = document.createElement("table");
resultTable.setAttribute("name", "hb_resultable");
resultTable.setAttribute("class", "h1btable");
resultTable.setAttribute("id", "h1b_result_table");
resultTable.innerHTML = response;
addModal(divToAttach, resultTable);
}
function addModal(divToAttach, resultTable) {
var modalDiv = document.createElement("div");
modalDiv.setAttribute("id", "myModal");
modalDiv.setAttribute("name", "myModal");
modalDiv.setAttribute("class", "h1bmodal");
modalDiv.style.display = "none";
modalDiv.style.overflow = "auto";
if (url.includes(Indeed)) {
modalDiv.style.width = "510px";
}
var modalContentDiv = document.createElement("div");
modalContentDiv.setAttribute("id", "myModalContent");
modalContentDiv.setAttribute("class", "h1bmodal-content");
modalContentDiv.style.maxHeight = "500px";
modalContentDiv.style.overflowY = "auto";
var modalHeader = document.createElement("div");
modalHeader.setAttribute("id", "modal-header");
modalHeader.setAttribute("class", "h1bmodal-header");
var modalBody = document.createElement("div");
modalBody.setAttribute("id", "modal-body");
modalBody.setAttribute("class", "h1bmodal-body");
var modalFooter = document.createElement("div");
modalFooter.setAttribute("id", "modal-footer");
modalFooter.setAttribute("class", "h1bmodal-footer");
var footerLink = document.createElement("a");
footerLink.setAttribute("name", "website_url");
footerLink.setAttribute("target", "_blank");
footerLink.href = "https://www.uscis.gov/tools/reports-and-studies/h-1b-employer-data-hub/understanding-our-h-1b-employer-data-hub";
footerLink.innerText = 'H-1B Employer Data Hub Glossary';
var supportSpan = document.createElement("span");
//supportSpan.setAttribute("class", "close");
//supportSpan.innerHTML = '<span>Paypal or Credit\\Debit Card </span><a href="https://www.buymeacoffee.com/kart33k" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 45px !important;width: 217px !important;"></a>';
var supportSpan1 = document.createElement("span");
//supportSpan1.setAttribute("class", "close");
// supportSpan1.innerHTML =
// `<span>Paypal or Credit\\Debit Card </span> <a href='https://ko-fi.com/V7V0GD4YJ' target='_blank'><img height='36' style='border:0px;height:36px;'src='https://storage.ko-fi.com/cdn/kofi2.png?v=3' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>`;
// modalFooter.appendChild(supportSpan);
// modalFooter.appendChild(supportSpan1);
// modalFooter.appendChild(footerLink);
var donationHtml = `
<table class="donation-table">
<thead>
<tr>
<th><span>Credit\\Debit Card</span></th>
<th><span>Paypal\\Venmo\\Credit\\Debit Card</span></th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="https://www.buymeacoffee.com/kart33k" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee"></a></td>
<td><a href="https://ko-fi.com/V7V0GD4YJ" target="_blank"><img src="https://storage.ko-fi.com/cdn/kofi2.png?v=3" alt="Buy Me a Coffee at ko-fi.com"></a></td>
</tr>
</tbody>
</table>
`;
supportSpan.innerHTML = donationHtml;
modalFooter.appendChild(footerLink);
modalFooter.appendChild(supportSpan);
var timesSpan = document.createElement("span");
timesSpan.setAttribute("class", "close");
timesSpan.innerHTML = "×";
timesSpan.style.float = "right";
timesSpan.style.fontSize = "28px";
timesSpan.style.fontWeight = "bold";
timesSpan.style.cursor = "pointer";
timesSpan.addEventListener("click", () => {
var modal = "";
if (url.includes(Indeed)) {
modal = getIndeedModal();
for (let index = 0; index < modal.length; index++) {
const element = modal[index];
element.style.display = "none";
}
} else {
modal = document.getElementById("myModal");
modal.style.display = "none";
}
});
var header = document.createElement("h3");
header.innerText = "Results";
//header.style.height = "50px";
modalHeader.appendChild(timesSpan);
modalHeader.appendChild(header);
modalBody.appendChild(resultTable);
modalContentDiv.appendChild(modalHeader);
modalContentDiv.appendChild(modalBody);
modalContentDiv.appendChild(modalFooter);
modalDiv.appendChild(modalContentDiv);
if (url.includes(Glassdoor)) {
document.body.appendChild(modalDiv);
} else if (url.includes(Indeed)) {
divToAttach.parentElement.insertAdjacentElement('afterend', modalDiv);
} else {
divToAttach.appendChild(modalDiv);
}
var modal = "";
if (url.includes(Indeed)) {
modal = getIndeedModal()
} else {
modal = document.getElementById("myModal");
}
document.onclick = function (event) {
if (event.target == modal) {
modal.style.display = "none";
} else if (event.target.id == "myBtn") {
getData()
if (url.includes(Indeed)) {
modal[0].style.display = "block";
} else modal.style.display = "block";
}
}
if (url.includes(Indeed)) {
var iframeDocuemnt = document.getElementById("vjs-container-iframe");
if (iframeDocuemnt) {
// Get the iframe's content document
var iframeDoc = iframeDocuemnt.contentDocument || iframeDocuemnt.contentWindow.document;
// Create a style element
var style = iframeDoc.createElement('style');
// Set the style element's type attribute
style.type = 'text/css';
// Set the style element's content
style.innerHTML = `
.myBtn {
cursor: pointer;
}
#myBtn{
cursor: pointer;
}
/* The Modal (background) */
.h1bmodal {
display: none;
/* Hidden by default */
position: fixed;
/* Stay in place */
z-index: 100;
/* Sit on top */
padding-top: 100px;
/* Location of the box */
left: 0;
top: 0;
width: 100% !important;
/* Full width */
height: 100%;
/* Full height */
overflow: auto;
/* Enable scroll if needed */
background-color: rgb(0, 0, 0);
/* Fallback color */
background-color: rgba(0, 0, 0, 0.4);
/* Black w/ opacity */
}
/* Modal Content */
.h1bmodal-content {
background-color: #fefefe;
margin: auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
height: auto;
max-height: 500px;
overflow-y: auto;
}
/* The Close Button */
.close {
/* color: white; */
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
.h1bmodal-header {
padding: 2px 16px;
background-color: #5cb85c;
color: white;
}
.h1bmodal-body {
padding: 2px 16px;
height: auto;
max-height: 300px;
overflow: scroll;
}
.h1bmodal-footer {
padding: 2px 16px;
background-color: aliceblue;
color: white;
}
#h1b_result_table {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
color: #000;
border: ridge;
}
#h1b_result_table td,
#h1b_result_table th {
border: 1px solid #ddd;
padding: 8px;
}
#h1b_result_table tr:nth-child(even) {
background-color: #f2f2f2;
}
#h1b_result_table tr:hover {
background-color: #ddd;
}
#h1b_result_table th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #006097;
color: white;
}
#h1b_result_table p {
color: black;
}
[sbadge]:after {
background: green;
border-radius: 30px;
color: #fff;
content: attr(sbadge);
font-size: 9px;
margin-top: -3px;
min-width: 20px;
padding: 1px;
position: absolute;
text-align: center;
}
[sbadge^="-"]:after,
[sbadge="0"]:after,
[sbadge=""]:after {
display: none;
}
[fbadge]:after {
background: red;
border-radius: 30px;
color: #fff;
content: attr(fbadge);
font-size: 9px;
margin-top: -3px;
min-width: 20px;
padding: 1px;
position: absolute;
text-align: center;
}
[fbadge^="-"]:after,
[fbadge="0"]:after,
[fbadge=""]:after {
display: none;
}
.donation-table {
color: #fff;
background-color: #333;
font-family: Arial, sans-serif;
font-size: 14px;
line-height: 1.5;
border-collapse: collapse;
width: 100%;
}
.donation-table th,
.donation-table td {
padding: 2px;
text-align: center;
}
.donation-table th span {
font-weight: bold;
}
.donation-table td span {
display: block;
}
.donation-table img {
height: 45px;
width: 217px;
border: 0;
}
/* Style the button */
.myBtn {
display: inline-block;
padding: 3px;
background-color: #4CAF50;
color: white;
font-size: 16px;
border: none;
border-radius: 5px;
cursor: pointer;
}
/* Hover effect */
.myBtn:hover {
background-color: #3e8e41;
}
/* Active effect */
.myBtn:active {
background-color: #3e8e41;
box-shadow: 0 5px #666;
transform: translateY(4px);
}
`;
// Append the style element to the iframe's head element
iframeDoc.head.appendChild(style);
iframeDocuemnt.contentWindow.document.onclick = function (event) {