// ==UserScript== // @name 音乐磁场自动回复隐藏帖 // @namespace https://greasyfork.org/zh-CN/scripts/507531 // @version 2024-12-18 // @description 自动回复音乐磁场论坛上的隐藏帖 // @author zhenhappy // @match https://www.hifini.com/thread-*.htm // @icon https://www.hifini.com/favicon.ico // @require https://unpkg.com/jquery/dist/jquery.slim.min.js // @run-at document-body // @license MIT // @downloadURL none // ==/UserScript== function waitForElm(selector) { let time1, time2 return new Promise(resolve => { if ($(selector).length > 0) return resolve($(selector)) time1 = setTimeout(() => { resolve(null) clearTimeout(time1) clearInterval(time2) }, 3000) time2 = setInterval(() => { if ($(selector).length > 0) { resolve($(selector)) clearTimeout(time1) clearInterval(time2) } }, 20) }) } $(document).ready(async function () { const success = await waitForElm('.alert-success') if (!success) { const message = await waitForElm('#message') if (message) { message.val('谢谢分享') setTimeout(() => { $('#submit').trigger('click') }, 500) } } })