Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
Fix DOM structure checkup, query is more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
muan committed May 8, 2019
1 parent 6128204 commit 89747ef
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const events = [
'team_add', 'member_add'
]

const eventClasses = events.map(e => `.${e}`).join()

let listOfFollowees

init()
Expand Down Expand Up @@ -185,17 +187,8 @@ async function addMoreSpecificIdentifiers(list) {
for (const record of list) {
if (!record.target.classList.contains('news')) continue

let eventItems = record.addedNodes
// Markup change workaround for events wrapped in an empty div
const firstNode = eventItems[0]
if (firstNode instanceof HTMLElement && firstNode.children && events.indexOf(firstNode.children[0].className) >= 0) {
eventItems = firstNode.children
}

for (const eventItem of eventItems) {
for (const eventItem of record.target.querySelectorAll(eventClasses)) {
if (!(eventItem instanceof HTMLElement)) continue
// eventItem should have only one className
if (events.indexOf(eventItem.className) < 0) continue

// Check if any links are to one of the followed people
const fromFollowedPeople = Array.from(eventItem.querySelectorAll('a')).some(function(maybeActor) {
Expand Down

0 comments on commit 89747ef

Please sign in to comment.