Created
November 23, 2020 06:18
-
-
Save liubiantao/29fae9346bb450763b27e47cff62d1a7 to your computer and use it in GitHub Desktop.
EHR系统辅助复制粘贴时间
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name EHR系统辅助复制粘贴时间 | |
// @namespace https://gist.github.com/liubiantao | |
// @version 0.1 | |
// @description 方便一键复制粘贴到excel里进行统计 | |
// @author liubiantao | |
// @match https://hr.saybot.net:8443/* | |
// @grant none | |
// ==/UserScript== | |
;(function () { | |
'use strict' | |
const observer = new MutationObserver(main) | |
const config = { | |
childList: true, | |
subtree: true, | |
} | |
function main() { | |
const targetDoms = document.querySelectorAll('.percheckq-time li > span') | |
if (targetDoms.length > 0) { | |
observer.disconnect() | |
document.querySelectorAll('.percheckq-time li > span').forEach((item) => { | |
console.log(item.innerText) | |
item.innerText = item.innerText.split(' ')[1] | |
item.addEventListener('click', () => { | |
navigator.clipboard.writeText(item.innerText) | |
item.style.color = '#2196f3' | |
setTimeout(() => { | |
item.style.color = '#333' | |
}, 500) | |
}) | |
}) | |
const timeDom = document.querySelector('.percheckq-time') | |
observer.observe(timeDom, config) | |
} | |
} | |
function init() { | |
setTimeout(() => { | |
const timeDom = document.querySelector('.percheckq-time') | |
if (timeDom) { | |
observer.observe(timeDom, config) | |
window.onbeforeunload = function () { | |
observer.disconnect() | |
} | |
} else { | |
init() | |
} | |
}, 1000) | |
} | |
init() | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment