解决98手机网页版复制代码只复制第一行问题
// ==UserScript==
// @name 98手机网页版复制代码增强
// @namespace http://tampermonkey.net/
// @version 1.5
// @description 解决98手机网页版复制代码只复制第一行问题
// @author bbbyqq
// @match *://*/forum.php?mod=viewthread*
// @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)
}
})()