slack指定消息触发自动回复脚本
function sendMessage(isAllowFun,text){
const flagStr = 'data-xxx-flag'
setInterval(()=>{
const msgReply = document.querySelector('.p-workspace__primary_view_footer .ql-editor')
const msgSend = document.querySelector('.p-workspace__primary_view_footer .c-wysiwyg_container__suffix .c-button-unstyled')
if (isAllowFun() && !msgReply.getAttribute(flagStr)) {
msgReply.innerHTML = `<p>${text}</p>`
msgReply.setAttribute(flagStr, 'true')
setTimeout(()=>{
msgSend.click()
},300)
}
},1500)
}
function getAllow(name,time,text){
try {
const domList = document.querySelectorAll(`[data-stringify-text="${name}"]`)
const lastDom =domList[domList.length-1]
const targetDom = lastDom.nextElementSibling
const parentDom=targetDom.parentNode
if(targetDom.getAttribute('data-stringify-text')>time && parentDom.innerText.includes(text)){
return true
}else {
return false
}
}catch {
return false
}
}
sendMessage(()=>getAllow("xxx","[晚上 9:06]",'xxx'),`xxx`)
编辑