// ==UserScript== // @name T-网站-目的 // @author tianyunperfect // @description 简介 // @version 1.0.0 // @update 2021-07-08 16:16:14 // @include *www.baidu.com* // @include *tieba.baidu.com* // @require https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js // ==/UserScript== function sleep(time) { return new Promise((resolve) => setTimeout(resolve, time)); } async function getDom(sel) { for (let i = 0; i < 100; i++) { let dom = document.querySelector(sel); console.log(dom); if (dom) { return dom; } else { await sleep(100); } } } (async () => { let a_href = (await getDom("#notion-app")).href; (await getDom("#notion-app ")).click(); let sel = "#notion-app"; let a_input = await getDom(sel); a_input.value = a_href; })();