content = content.replace(/]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi, '[Link]') // replace url content = content.replace(/
.*?<\/pre>/gi, '[Code]') // replace code
    content = content.replace(/.*?<\/code>/gi, '[Code]') // replace code      
    content = content.replace(/<[^>]+>/g, "") // remove html tag

    if (content.length > 150) {
      content = content.substring(0, 150) + '...'
    }
    return content
  },

  generateHtml: (array, ele) => {
    let result = ''

    if (array.length) {
      for (let i = 0; i < array.length; i++) {
        result += '
' if (true && array[i].avatar) { const imgAttr = 'src' result += `${array[i].nick}` } result += `
${array[i].content}
${array[i].nick} /
` } } else { result += 'No comments' } ele.innerHTML = result window.lazyLoadInstance && window.lazyLoadInstance.update() window.pjax && window.pjax.refresh(ele) }, newestCommentInit: (name, getComment) => { const $dom = document.querySelector('#card-newest-comments .aside-list') if ($dom) { const data = btf.saveToLocal.get(name) if (data) { newestComments.generateHtml(JSON.parse(data), $dom) } else { getComment($dom) } } }, run: (name, getComment) => { newestComments.newestCommentInit(name, getComment) btf.addGlobalFn('pjaxComplete', () => newestComments.newestCommentInit(name, getComment), name) } }