<commit_before>var browser = browser || chrome

let filters = []

browser.runtime.sendMessage({ type: 'get-filters' }, getFilters)
browser.runtime.onMessage.addListener(getFilters)

function getFilters(upToDateFilters) {
  filters = upToDateFilters
  hideVideos()
}

function hideVideos() {
  const lis = document.getElementsByClassName('yt-shelf-grid-item')
  if (filters.length === 1 && filters[0].length === 0) {
    for (const li of lis) {
      if (li.style.display === 'none') {
        const title = li.querySelector('h3 > a').innerHTML
        console.log('Displaying "' + title + '"')
        li.style.display = 'inline-block'
      }
    }

    return
  }

  const videosToHide = filters.map(title => title.toUpperCase())
  const videos = {}

  for (const li of lis) {
    const title = li.querySelector('h3 > a').innerHTML
    const upperCaseTitle = title.toUpperCase()
    if (new RegExp(videosToHide.join('|')).test(upperCaseTitle)) {
      console.log('Hiding "' + title + '"')
      li.style.display = 'none'
    } else if (li.style.display === 'none') {
      console.log('Displaying "' + title + '"')
      li.style.display = 'inline-block'
    }
  }
}
<commit_msg>Better logs: display number of videos hiding/displaying<commit_after>var browser = browser || chrome

let filters = []

browser.runtime.sendMessage({ type: 'get-filters' }, getFilters)
browser.runtime.onMessage.addListener(getFilters)

function getFilters(upToDateFilters) {
  filters = upToDateFilters
  hideVideos()
}

function hideVideos() {
  const lis = document.getElementsByClassName('yt-shelf-grid-item')

  if (filters.length === 1 && filters[0].length === 0) {
    for (const li of lis) {
      if (li.style.display === 'none') {
        const title = li.querySelector('h3 > a').innerHTML
        console.log('Displaying "' + title + '"')
        li.style.display = 'inline-block'
      }
    }

    return
  }

  const videosToHide = filters.map(title => title.toUpperCase())
  const videos = {}
  const displayedVideos = []
  const hiddenVideos = []

  for (const li of lis) {
    const title = li.querySelector('h3 > a').innerHTML
    const upperCaseTitle = title.toUpperCase()
    if (new RegExp(videosToHide.join('|')).test(upperCaseTitle)) {
      hiddenVideos.push(title)
      li.style.display = 'none'
    } else if (li.style.display === 'none') {
      displayedVideos.push(title)
      li.style.display = 'inline-block'
    }
  }

  if (hiddenVideos.length > 0) {
    console.groupCollapsed(`Hiding ${hiddenVideos.length} videos`)

    for (const title of hiddenVideos) {
      console.log(title)
    }

    console.groupEnd()
  }

  if (displayedVideos.length > 0) {
    console.groupCollapsed(`Displaying ${displayedVideos.length} videos`)

    for (const title of displayedVideos) {
      console.log(title)
    }

    console.groupEnd()
  }
}

{'fraction_non_alphanumeric': 0.14666666666666667, 'fraction_numerical': 0.004210526315789474, 'mean_word_length': 3.21122599704579, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4831403', 'n_tokens_mistral': 941, 'n_tokens_neox': 911, 'n_words': 186}