AHK中文社区代码区双击复制
当前为
// ==UserScript==
// @name AHK双击复制代码
// @namespace http://tampermonkey.net/
// @version 0.1
// @description AHK中文社区代码区双击复制
// @author AHK社区昵称:北极星
// @match https://www.autoahk.com/*
// @icon https://www.google.com/s2/favicons?domain=autoahk.com
// @license MIT
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_setClipboard
// @grant GM_log
// @grant GM_xmlhttpRequest
// @grant unsafeWindow
// @grant window.close
// @grant window.focus
// ==/UserScript==
(function() {
'use strict';
// Your code here...
document.ondblclick=function(event){
let ele = event.target
while((ele.parentNode.tagName) != "PRE"){
ele = ele.parentNode
}
let preele = ele.parentNode
let copytext = preele.innerText
let selObj = window.getSelection()
selObj.selectAllChildren(preele)
navigator.clipboard.writeText(copytext)
alert("Code Copied!")
}
})();