SOURCE

console 命令行工具 X clear

                    
>
console
// const str = "<div class=\"lazyimg\"><p><a href=\"https://cuxiao.suning.com/hd20161212.html\" target=\"_blank\"><img data-src=\"https://image.suning.cn/uimg/sop/commodity/362052609798551643879700_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"https://image.suning.cn/uimg/sop/commodity/362052609798551643879700_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"></a></p><div moduleid=\"R0503002_2\" modulename=\"关联推荐\"><p><img data-src=\"//image.suning.cn/uimg/sop/commodity/150140884120977750127147_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/150140884120977750127147_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"></p><!-- Save for Web Slices (18.jpg) --><p><img data-src=\"https://image.suning.cn/uimg/sop/commodity/777168221141135616765490_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" usemap=\"#Map\" border=\"0\" src=\"https://image.suning.cn/uimg/sop/commodity/777168221141135616765490_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"> </p><!-- End Save for Web Slices --><p> </p></div><div moduleid=\"customize_R0503002_1\" modulename=\"温馨提示\"><p><img data-src=\"https://image.suning.cn/uimg/sop/commodity/758660134135998588410860_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"https://image.suning.cn/uimg/sop/commodity/758660134135998588410860_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"></p></div><div moduleid=\"R0503002_3\" modulename=\"商品详情\"><p><img data-src=\"//image.suning.cn/uimg/sop/commodity/202928157563209965045130_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/202928157563209965045130_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"><img data-src=\"//image.suning.cn/uimg/sop/commodity/594195494845564661008000_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/594195494845564661008000_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"><img data-src=\"//image.suning.cn/uimg/sop/commodity/173139298974561690812500_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/173139298974561690812500_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"><img data-src=\"https://image.suning.cn/uimg/sop/commodity/227936067137952395866430_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"https://image.suning.cn/uimg/sop/commodity/227936067137952395866430_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"><img data-src=\"//image.suning.cn/uimg/sop/commodity/106767702651758444093100_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/106767702651758444093100_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"><img data-src=\"//image.suning.cn/uimg/sop/commodity/990396776196284564580330_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/990396776196284564580330_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"><img data-src=\"//image.suning.cn/uimg/sop/commodity/164156400210312524144962_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/164156400210312524144962_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"><img data-src=\"//image.suning.cn/uimg/sop/commodity/195831485175689218372040_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/195831485175689218372040_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"><img data-src=\"//image.suning.cn/uimg/sop/commodity/150962652517446585616757_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/150962652517446585616757_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"><img data-src=\"//image.suning.cn/uimg/sop/commodity/481763324211713337953860_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/481763324211713337953860_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"><img data-src=\"//image.suning.cn/uimg/sop/commodity/103859356316935550702867_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/103859356316935550702867_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"><img data-src=\"//image.suning.cn/uimg/sop/commodity/108357483221028413063740_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/108357483221028413063740_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"><img data-src=\"//image.suning.cn/uimg/sop/commodity/549645912133212956344880_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/549645912133212956344880_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"><img data-src=\"//image.suning.cn/uimg/sop/commodity/131537498448017935386040_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"//image.suning.cn/uimg/sop/commodity/131537498448017935386040_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"></p></div><div moduleid=\"R0503002_6\" modulename=\"安装说明\"><p><a href=\"https://sale.suning.com/shfw/cdaz/index.html#suning\" target=\"_blank\"><img data-src=\"https://image.suning.cn/uimg/sop/commodity/127297268581783677331000_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"https://image.suning.cn/uimg/sop/commodity/127297268581783677331000_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"></a><img data-src=\"https://image.suning.cn/uimg/sop/commodity/505795155114867224752850_x.jpg?from=mobile&amp;format=80q.webp\" alt=\"\" src=\"https://image.suning.cn/uimg/sop/commodity/505795155114867224752850_x.jpg?from=mobile&format=80q.webp\" width=\"100%\" height=\"auto\"></p></div></div>"
// console.log(str.replace(/\"/g,"'"))
// const copy_srt = str.replace(/\"/g,"'")

document.getElementById("code").addEventListener("click",()=>{
    const str = document.getElementById("old_code").value
    console.log(str)
    const new_str = str.replace(/\\"/g,"'")
    document.getElementById("new_code").value = new_str
})

document.getElementById("copy").addEventListener("click",async ()=>{
    const str = document.getElementById("new_code").value || ''
    await navigator.clipboard.writeText(str)
    document.getElementsByClassName("vivi")[0].style.display = "block"
    setTimeout(()=>{
        document.getElementsByClassName("vivi")[0].style.display = "none"
    },1000)
})
<div class="box">
    <textarea id="old_code"></textarea>
    <textarea id="new_code"></textarea>
</div>


<button id="code">转义</button>
<button id="copy">复制</button>

<div class="vivi">复制成功</div>
textarea {
    width: 50%;
    height: 200px;
}
.box{
    display: flex;
}
.vivi{
    position: absolute;
    background-color: rgba(0, 0, 0, .3);
    color: #fff;
    padding: 5px  10px;
    border-radius: 7px;
    top: 50%;
    left:50%;
    transform: translate(-50%,-50%);
    display: none;
}