function applyStyle() { let lineNumbers = document.body.querySelectorAll('[class^="language-"].line-numbers-mode') lineNumbers.forEach((item) => { // 插入现成的html文本 let title = item.getAttribute('data-title') let tabStr = "
" + "
" + "
" + "
" + "
" + "
" + `
${title}
` + "
" + "
" // 在代码块前插入选项卡 item.insertAdjacentHTML('beforebegin', tabStr); }) } applyStyle()