-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.js
50 lines (41 loc) · 1.48 KB
/
scripts.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
var hasData = false;
chrome.runtime.sendMessage({action: 'listenForReady'}, addClasses);
chrome.runtime.onMessage.addListener(function(msg, sender, sendResponse) {
if (msg.action == 'addClasses') {
addClasses(msg);
}
});
function addClasses(data) {
if (hasData || !data || !data.state) return;
hasData = true;
new MutationObserver(onMutation).observe(document, {
childList: true, // report added/removed nodes
subtree: true, // observe any descendant elements
});
function onMutation(mutations, observer) {
var ratingsElem = document.getElementById('nav_ratings');
if (!ratingsElem) return;
switch (data.state) {
case 'hide':
ratingsElem.className += ' hide_count';
break;
case 'color':
ratingsElem.className += ' disable_color';
break;
case 'changeLabel':
ratingsElem.className += ' change_label';
ratingsElem.getElementsByClassName("navbar-link-text")[0].innerText = "Intros";
ratingsElem.href="/intros";
ratingsElem.onclick = function() {
window.location.href="https://www.okcupid.com/intros";
};
break;
case 'default':
ratingsElem.className += ' do_nothing';
break;
default:
// Do nothing
}
observer.disconnect();
}
}