-
Notifications
You must be signed in to change notification settings - Fork 0
/
addDetails.js
161 lines (131 loc) · 5.57 KB
/
addDetails.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
/***********
* Import Gmoot data
***********/
var gmootData = [];
try {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", "chrome-extension://" + chrome.runtime.id + "/gmootData.json", false);
xmlHttp.send(null);
gmootData = xmlHttp.responseText;
gmootData = JSON.parse(gmootData).data;
} catch(e) {
console.log(e);
}
/***********
* Import Gmoot Unique Item data
***********/
var gmootUniqueItemData = [];
try {
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", "chrome-extension://" + chrome.runtime.id + "/gmootUniqueItemData.json", false);
xmlHttp.send(null);
gmootUniqueItemData = xmlHttp.responseText;
gmootUniqueItemData = JSON.parse(gmootUniqueItemData);
} catch(e) {
console.log(e);
}
var uniqueArmor = [];
var uniqueHeadwear = [];
var uniqueFootwear = [];
var uniqueWeapon = [];
if (gmootUniqueItemData != null) {
uniqueArmor = gmootUniqueItemData.uniqueArmor;
uniqueHeadwear = gmootUniqueItemData.uniqueHeadwear;
uniqueFootwear = gmootUniqueItemData.uniqueFootwear;
uniqueWeapon = gmootUniqueItemData.uniqueWeapon;
}
/***********
* Set Gmoot Styles
***********/
if (typeof gmootOneOfOneStyles == 'undefined') {
let gmootOneOfOneStyles = '.gmootMultipleOneOfOnes {-webkit-animation: glow 1s ease-in-out infinite alternate;-moz-animation: glow 1s ease-in-out infinite alternate;animation: glow 1s ease-in-out infinite alternate;}@-webkit-keyframes glow {from {box-shadow: 0 0 5px #000, 0 0 10px #000, 0 0 15px #700, 0 0 20px #700, 0 0 25px #700, 0 0 30px #700, 0 0 35px #700;}to {box-shadow: 0 0 10px #000, 0 0 15px #A00, 0 0 20px #A00, 0 0 25px #A00, 0 0 30px #A00, 0 0 35px #A00, 0 0 40px #A00;}}.gmootSingleOneOfOne {-webkit-animation: glow2 1s ease-in-out infinite alternate;-moz-animation: glow2 1s ease-in-out infinite alternate;animation: glow2 1s ease-in-out infinite alternate;}@-webkit-keyframes glow2 {from {box-shadow: 0 0 5px #000, 0 0 10px #000, 0 0 15px #770, 0 0 20px #770, 0 0 25px #770, 0 0 30px #770, 0 0 35px #770;}to {box-shadow: 0 0 10px #000, 0 0 15px #AA0, 0 0 20px #AA0, 0 0 25px #AA0, 0 0 30px #AA0, 0 0 35px #AA0, 0 0 40px #AA0;}}';
head = document.head || document.getElementsByTagName('head')[0],
style = document.createElement('style');
head.appendChild(style);
style.type = 'text/css';
if (style.styleSheet) {
style.styleSheet.cssText = gmootOneOfOneStyles;
} else {
style.appendChild(document.createTextNode(gmootOneOfOneStyles));
}
}
var loadAllData = function() {
/***********
* Clear existing UI elements
***********/
if (typeof gmootMarketHelpers != 'undefined') { gmootMarketHelpers = null; }
var gmootMarketHelpers = document.getElementsByClassName('gmootMarketHelper');
while (gmootMarketHelpers.length > 0) {
gmootMarketHelpers[0].parentNode.removeChild(gmootMarketHelpers[0]);
}
/***********
* Selectors for different marketplaces [DE,ME]
***********/
var selectors = ['p.text-color-main-secondary','h6.mb-0'];
selectors.forEach(selectorString => {
document.querySelectorAll(selectorString).forEach(e => {
/***********
* Gmoot
***********/
if (e.textContent.toLowerCase().indexOf('gmoot') > -1) {
var gmootDetailElement = document.createElement('p');
gmootDetailElement.classList.add('gmootMarketHelper');
var bagNumber = e.textContent.replace(/\D/g, '');
if (bagNumber != null && bagNumber != '') {
for (let i = 0; i < gmootData.length; i++) {
if (gmootData[i]['#'] == bagNumber) {
gmootDetailElement.textContent = 'Rank: ' + gmootData[i]['Ranking'];
let oneOfOnes = "";
let oneOfOneEmojis = "";
if (uniqueArmor.indexOf(gmootData[i]['armor']) > -1) {
oneOfOnes += "A";
oneOfOneEmojis += "🛡️";
}
if (uniqueFootwear.indexOf(gmootData[i]['footwear']) > -1) {
oneOfOnes += "F";
oneOfOneEmojis += "👟";
}
if (uniqueHeadwear.indexOf(gmootData[i]['headwear']) > -1) {
oneOfOnes += "H";
oneOfOneEmojis += "🧢";
}
if (uniqueWeapon.indexOf(gmootData[i]['weapon']) > -1) {
oneOfOnes += "W";
oneOfOneEmojis += "🗡️";
}
try {
if (oneOfOnes.length == 1) {
e.closest('li').classList.add("gmootSingleOneOfOne");
} else if (oneOfOnes.length > 1) {
e.closest('li').classList.add("gmootMultipleOneOfOnes");
}
} catch (e) {
console.log("Magic Eden tsk tsk");
}
if (oneOfOnes.length > 0) {
gmootDetailElement.textContent += ". 1/1: " + oneOfOneEmojis;
}
if (gmootData[i]['Ranking'] < 500) {
e.style.color = "orange";
} else if (gmootData[i]['Ranking'] < 1000) {
e.style.color = "purple";
} else if (gmootData[i]['Ranking'] < 2500) {
e.style.color = "blue";
} else if (gmootData[i]['Ranking'] < 4000) {
e.style.color = "green";
} else {
e.style.color = "grey";
}
}
}
e.parentNode.insertBefore(gmootDetailElement, e.nextSibling);
}
}
});
});
}
/***********
* Run on click and then loop every 2 sec
***********/
loadAllData();
setInterval(loadAllData, 2000);