mirror of
https://github.com/wassname/chatGPTBox.git
synced 2026-07-09 23:25:22 +08:00
fix mounting failure caused by DuckDuckGo's initial rendering delay. #610
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
export function waitForElementToExistAndSelect(selector) {
|
||||
export function waitForElementToExistAndSelect(selector, timeout = 0) {
|
||||
return new Promise((resolve) => {
|
||||
if (document.querySelector(selector)) {
|
||||
return resolve(document.querySelector(selector))
|
||||
@@ -15,5 +15,11 @@ export function waitForElementToExistAndSelect(selector) {
|
||||
subtree: true,
|
||||
childList: true,
|
||||
})
|
||||
|
||||
if (timeout)
|
||||
setTimeout(() => {
|
||||
observer.disconnect()
|
||||
resolve(null)
|
||||
}, timeout)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user