98手机网页版复制代码增强

解决98手机网页版复制代码只复制第一行问题

// ==UserScript==
// @name         98手机网页版复制代码增强
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  解决98手机网页版复制代码只复制第一行问题
// @author       bbbyqq
// @match        https://sehuatang.org/forum.php*
// @match        https://www.sehuatang.org/forum.php*
// @match        https://sehuatang.net/forum.php*
// @match        https://www.sehuatang.net/forum.php*
// @match        https://30fjp.com/forum.php*
// @match        https://www.30fjp.com/forum.php*
// @match        https://jq2t4.com/forum.php*
// @match        https://www.jq2t4.com/forum.php*
// @match        https://xo6c5.com/forum.php*
// @match        https://www.xo6c5.com/forum.php*
// @license      bbbyqq
// ==/UserScript==

(function () {
  'use strict'

  document.querySelectorAll('.blockbtn').forEach(btn => {
    btn.addEventListener('click', () => {
      const id = btn.getAttribute('data-clipboard-target')
      const code = []
      document.querySelector(id).parentNode.querySelectorAll('li').forEach(item => {
        code.push(item.innerText)
      })
      const codeText = code.join('\n')
      setTimeout(() => {
        copyContent(codeText)
      }, 500)
    })
  })

  function copyContent (text) {
    const textarea = document.createElement('textarea')
    textarea.value = text
    document.body.appendChild(textarea)
    textarea.select()
    document.execCommand('copy')
    document.body.removeChild(textarea)
  }

})()