-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathscript.js
228 lines (134 loc) · 4.42 KB
/
script.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
var status = document.getElementById("status");
var mainContainer = document.getElementById("siteList");
var filter = "all";
status.innerHTML = "Fetching...";
function filterProviders() {
$("li").each(function () {
if (filter === "all") {
$(this).show();
} else if (
$(this)
.find(".siteValues")
.text()
.toLowerCase()
.indexOf(filter.toLowerCase()) === -1
) {
$(this).hide();
} else {
$(this).show();
}
});
}
$("input[name='filter']").on("change", function () {
filter = this.value;
filterProviders();
});
$(document).ready(function () {
$.getJSON("https://raw.githack.com/OshekharO/Web-Indexer/main/providers.json", function (data) {
status.innerHTML = "Parsing...";
for (var key in data) {
status.innerHTML = "Reading..." + key;
if (data.hasOwnProperty(key)) {
var value = data[key];
if (value.url == "NONE") {
continue;
}
var _status = value.status;
var _thumbNail = "https://cdn-cmlep.nitrocdn.com/DLSjJVyzoVcUgUSBlgyEUoGMDKLbWXQr/assets/images/optimized/rev-ea26883/www.stellarinfo.com/images/v7/dmca.png";
//Use defaut image if missing
if (value.hasOwnProperty("icon")) {
_thumbNail = value.icon;
}
//Create <li> node
var node = document.createElement("li");
//Add <div> to <li> node for items
var _divMain = document.createElement("div"); //group below divs
var _divImg = document.createElement("div"); //for image Thumbnail
var _divText = document.createElement("div"); //for sitename + status
var _img = document.createElement("img"); //Image thumbnail
//Add image
_img.className = "thumbnail";
_img.style.content = "";
_img.src = _thumbNail || "https://cdn-cmlep.nitrocdn.com/DLSjJVyzoVcUgUSBlgyEUoGMDKLbWXQr/assets/images/optimized/rev-ea26883/www.stellarinfo.com/images/v7/dmca.png";
_img.alt = "icon";
_img.loading = "lazy"; // Add this line to enable lazy loading
_img.onerror = function () {
_img.src = "https://cdn-cmlep.nitrocdn.com/DLSjJVyzoVcUgUSBlgyEUoGMDKLbWXQr/assets/images/optimized/rev-ea26883/www.stellarinfo.com/images/v7/dmca.png"; // Use a default image if loading fails
};
//_img.src = "https://via.placeholder.com/150";
//_img.src = value.url.trimRight("/") + "/favicon.ico";
//Modify _divImg
_divImg.className = "divthumb";
_divImg.appendChild(_img);
_divMain.appendChild(_divImg);
//Add siteName hyperlink text
var _a = document.createElement("a");
_a.setAttribute("href", value.url);
_a.innerHTML = value.name;
_a.title = key;
_a.style.color = "#fff";
_a.className = "siteName";
_divText.appendChild(_a);
//Add status label
var _p = document.createElement("p");
_p.innerHTML = "Type: ";
_p.className = "siteLabels";
//Add status from json
var _span = document.createElement("span");
_span.className = "siteValues";
var _statusText = "Unknown";
var _statusColor = "#eee";
switch (_status) {
case 1:
_statusText = "MANGA";
_statusColor = "#8bc34a";
break;
case 2:
_statusText = "LN";
_statusColor = "#ffc107";
break;
case 3:
_statusText = "MOVIE";
_statusColor = "#64b5f6";
break;
case 4:
_statusText = "APP";
_statusColor = "#64b5f6";
break;
case 5:
_statusText = "ANIME";
_statusColor = "#64b5f6";
break;
}
_span.style.color = _statusColor;
_span.textContent = _statusText;
_p.appendChild(_span);
//Add (status + status label) to _divText
_divText.appendChild(_p);
//Add type, if it exists
if (value.hasOwnProperty("type")) {
var _pType = document.createElement("p");
_pType.innerHTML = "Type: ";
_pType.className = "siteLabels";
var _spanType = document.createElement("span");
_spanType.className = "siteValues";
_spanType.textContent = value.type;
_pType.appendChild(_spanType);
_divText.appendChild(_pType);
}
//Add all texts for entry
_divText.className = "divcaption";
_divMain.appendChild(_divText);
//Add main container to node
_divMain.className = "divMainContainer";
node.appendChild(_divMain);
//Add <li> to <ul> siteList
mainContainer.appendChild(node);
}
}
}).fail(function () {
console.log("An error has occurred.");
status.innerHTML = "Error occured!";
});
});
status.innerHTML = "Done loading!";