Repository navigation
Expand file tree
/
Copy pathtest2.js
More file actions
89 lines (76 loc) · 2.86 KB
/
Copy pathtest2.js
File metadata and controls
89 lines (76 loc) · 2.86 KB
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
(function() {
'use strict';
function colorizeRatings() {
var rateElements = document.querySelectorAll('.full-start__rate > div, .info__rate > span');
for (var i = 0; i < rateElements.length; i++) {
var element = rateElements[i];
var rating = parseFloat(element.textContent.trim());
element.style.background = 'rgba(0, 0, 0, 0.8)';
if (rating >= 0 && rating <= 3) {
element.style.color = '#e74c3c';
} else if (rating > 3 && rating <= 5) {
element.style.color = '#e67e22';
} else if (rating > 5 && rating <= 6.5) {
element.style.color = '#f1c40f';
} else if (rating > 6.5 && rating < 8) {
element.style.color = '#3498db';
} else if (rating >= 8 && rating <= 10) {
element.style.color = '#2ecc71';
}
}
var cardVoteElements = document.querySelectorAll('.card__vote');
for (var j = 0; j < cardVoteElements.length; j++) {
var cardElement = cardVoteElements[j];
var cardRating = parseFloat(cardElement.textContent.trim());
if (cardRating >= 0 && cardRating <= 3) {
cardElement.style.color = '#e74c3c';
} else if (cardRating > 3 && cardRating <= 5) {
cardElement.style.color = '#e67e22';
} else if (cardRating > 5 && cardRating <= 6.5) {
cardElement.style.color = '#f1c40f';
} else if (cardRating > 6.5 && cardRating < 8) {
cardElement.style.color = '#3498db';
} else if (cardRating >= 8 && cardRating <= 10) {
cardElement.style.color = '#2ecc71';
}
}
}
function initPlugin() {
colorizeRatings();
}
function setupMutationObserver() {
var observer = new MutationObserver(function() {
colorizeRatings();
});
observer.observe(document.body, {
childList: true,
subtree: true
});
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', function() {
initPlugin();
setupMutationObserver();
});
} else {
initPlugin();
setupMutationObserver();
}
if (window.appready) {
initPlugin();
setupMutationObserver();
} else {
Lampa.Listener.follow('appready', function(event) {
if (event.type == 'ready') {
initPlugin();
setupMutationObserver();
}
});
}
Lampa.Listener.follow('app', function(event) {
if (event.type == 'ready') {
initPlugin();
setupMutationObserver();
}
});
})();