문서 편집 권한이 없습니다. 다음 이유를 확인해주세요: 여기에는 다른 사용자의 개인 설정이 포함되어 있기 때문에 이 자바스크립트 문서를 편집할 수 없습니다. 문서의 원본을 보거나 복사할 수 있습니다. function addCopyLinkToCodeElements() { const elements = document.querySelectorAll(".mw-parser-output .mw-highlight"); elements.forEach(function(element) { const copybutton = document.createElement('button'); const code = element.firstChild.innerText; copybutton.innerText = "copy"; copybutton.addEventListener('click', function() { copyCode(code); copybutton.innerText = "copy!"; setTimeout(function(){ copybutton.innerText = "copy"; }, 500); }); copybutton.style = "float:right; margin-left: -9999999px; margin-top: 0.7em; margin-right: 0.7em;"; const endBlock = document.createElement('div'); endBlock.style = "clear:both"; element.prepend(copybutton); element.appendChild(endBlock); }); } function copyCode(codeText) { navigator.clipboard.writeText(codeText); } $(function() {addCopyLinkToCodeElements()}); 사용자:하늘/addCopyButtonToCode.js 문서로 돌아갑니다.