js/options.js
// parse form string into array of filter object
parse form string into array of filter object
parse form string into array of filter object
function parseFilters (str) {
    const lines = str.split('\n')
    const res = {
      filters: [],
      errorLine: 0
    }
    for (const [i, l] of lines.entries()) {
      const s = l.trim()
      if (s.length === 0) continue
      const entry = s.match(/(user|chan):(\d+)/)
      if (entry?.length === 3) {
        const userId = entry[1] === 'user' ? entry[2] : ''
        const chanId = entry[1] === 'chan' ? entry[2] : ''
        res.filters.push({
          user: userId,
          chan: chanId
        })
      } else {
        res.errorLine = i + 1
        break
      }
    }
    res.filters = utils.uniqFilters(res.filters)
    return res
  }
function parseFilters ( str ) { const lines = str . split ( '\n' ) const res = { filters : [ ] , errorLine : 0 } for ( const [ i , l ] of lines . entries ( ) ) { const s = l . trim ( ) if ( s . length === 0 ) continue const entry = s . match ( / (user|chan):(\d+) / ) if ( entry ?. length === 3 ) { const userId = entry [ 1 ] === 'user' ? entry [ 2 ] : '' const chanId = entry [ 1 ] === 'chan' ? entry [ 2 ] : '' res . filters . push ( { user : userId , chan : chanId } ) } else { res . errorLine = i + 1 break } } res . filters = utils . uniqFilters ( res . filters ) return res }
parse form string into array of filter object
parse form string into array of filter object