Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // get the top-level comments in a hacker news thread
- [].slice.call(document.querySelectorAll('.comment'))
- .filter((el) => {
- var getSiblings = function ( elem ) {
- var siblings = []
- var sibling = elem.parentNode.firstChild
- for (; sibling; sibling = sibling.nextSibling) {
- if (sibling.nodeType === 1 && sibling !== elem) {
- siblings.push(sibling)
- }
- }
- return siblings
- }
- // a transparent 1px gif will have a width of 0 if it is a top-level comment in the comment-tree table
- return getSiblings(el.parentElement)
- .filter((sib) => sib.className.includes('ind') && sib.firstChild.width > 0)
- .length === 0
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement