-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathByeStars-Bye.user.js
76 lines (60 loc) · 2.14 KB
/
ByeStars-Bye.user.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
// ==UserScript==
// @name Bye Stars, Bye!
// @namespace stackuserflow
// @version 0.1.1
// @description Fazendo um mundo melhor
// @author Guilherme Nascimento (https://github.com/brcontainer)
// @match *://chat.stackoverflow.com/rooms/*
// @match *://chat.stackexchange.com/rooms/*
// @exclude *://chat.stackoverflow.com/rooms/info/*
// @exclude *://chat.stackexchange.com/rooms/info/*
// @downloadURL https://github.com/stackuserflow/stackoverflow-tampermonkey-greasemonkey/raw/master/ByeStars-Bye.user.js
// @updateURL https://github.com/stackuserflow/stackoverflow-tampermonkey-greasemonkey/raw/master/ByeStars-Bye.user.js
// @grant none
// ==/UserScript==
(function (d) {
'use strict';
function ByeStarBye(c)
{
if (c.tagName === 'LI' && c.querySelector('.owner-star')) {
if (!c.classList.contains('byestar-bye')) {
c.classList.add('byestar-bye');
}
} else {
c.classList.remove('byestar-bye');
}
}
function loadCss()
{
var style = d.createElement('style');
style.type = 'text/css';
style.textContent = '.byestar-bye { display: none !important; }';
d.head.appendChild(style);
}
function trigger()
{
loadCss();
var inUpdate, target = d.querySelector('#starred-posts ul');
var lis = target.querySelectorAll('li');
for (var i = lis.length - 1; i >= 0; i--) {
ByeStarBye(lis[i]);
}
var observer = new MutationObserver(function (mutations) {
if (inUpdate) { return; }
inUpdate = true;
mutations.forEach(function (mutation) {
ByeStarBye(mutation.target);
});
inUpdate = false;
});
observer.observe(target, {
'attributes': true,
'subtree': true
});
}
if (/^(interactive|complete)$/i.test(d.readyState)) {
trigger();
} else {
d.addEventListener('DOMContentLoaded', trigger);
}
})(document);