.js/lobste.rs.js

changeset 679
2c32255d5c84
parent 678
4c569c2420f1
child 680
b89661b25b51
equal deleted inserted replaced
678:4c569c2420f1 679:2c32255d5c84
1 // If story previews are enabled, set regular spacing and place byline below
2 // title.
3 if (document.querySelector('div.story_content')) {
4 var sheet = document.createElement('style')
5 sheet.innerHTML = "\
6 ol.list li.story { height: 9em; } \
7 li.story div.byline { color: #777; } \
8 li.story div.byline a { color: #777; } \
9 li.story div.story_content { color: #999; font-size: 95%; max-height: 3em !important; }"
10 document.body.appendChild(sheet)
11
12 var bylines = document.querySelectorAll('div.story_content + div.byline')
13 for (var e of bylines) {
14 e.parentNode.insertBefore(e, e.previousElementSibling)
15 }
16 }
17
18 // only safe when you've guaranteed a parent matches
19 function parentSelector (el, selector) {
20 while ((el = el.parentElement) && !el.matches(selector));
21 return el;
22 }
23
24 ['angersock'].forEach(function (u) {
25 var collapse = document.querySelectorAll('div.comment > div.details > div.byline > a[href="/u/' + u + '"]')
26 for (var el of collapse) {
27 parentSelector(el, 'div.comment').previousElementSibling.click()
28 }
29 })

mercurial