人狠话不多,先来看张图
再加个一键复制提取码的功能,下面的代码直接丢到主题设置-自定义JS代码中
//密码复制
if(document.querySelectorAll(".but-download .badg")!=undefined){const reg = /[a-zA-z0-9]/ig;const copy1 = document.querySelectorAll(".but-download .badg");for (let i = 0;i < copy1.length;i++){copy1[i].index = i;copy1[i].setAttribute("data-before","点击复制");copy1[i].addEventListener("click",copyOperation);copy1[i].addEventListener("mouseout",copyOk);}function copyOperation(){var oInput = document.createElement("input");let text = this.innerText;text = text.match(reg).join("");oInput.value = text;document.body.appendChild(oInput);oInput.select();document.execCommand("Copy");oInput.className = "oInput";oInput.style.display = "none";this.setAttribute("data-before","已复制");}function copyOk(){setTimeout(() =>{this.setAttribute("data-before","点击复制");},300)}}
本文资源整理自网络,仅供学习和研究使用,请在下载后24小时内删除,谢谢合作!
本站所有资源站长均亲自测试过,确认能正常使用
© 版权声明
本文结束
- 最新
- 最热
只看作者