mirror of
https://github.com/wassname/chatGPTBox.git
synced 2026-07-21 12:30:21 +08:00
chore: mount retry (#9)
This commit is contained in:
@@ -19,15 +19,24 @@ import Browser from 'webextension-polyfill'
|
||||
* @param {UserConfig} userConfig
|
||||
*/
|
||||
async function mountComponent(siteConfig, userConfig) {
|
||||
if (
|
||||
!getPossibleElementByQuerySelector(siteConfig.sidebarContainerQuery) &&
|
||||
!getPossibleElementByQuerySelector(siteConfig.appendContainerQuery) &&
|
||||
!getPossibleElementByQuerySelector(siteConfig.sidebarContainerQuery) &&
|
||||
!getPossibleElementByQuerySelector([userConfig.prependQuery]) &&
|
||||
!getPossibleElementByQuerySelector([userConfig.appendQuery])
|
||||
)
|
||||
return
|
||||
|
||||
const retry = 10
|
||||
for (let i = 1; i <= retry; i++) {
|
||||
const e =
|
||||
getPossibleElementByQuerySelector(siteConfig.sidebarContainerQuery) ||
|
||||
getPossibleElementByQuerySelector(siteConfig.appendContainerQuery) ||
|
||||
getPossibleElementByQuerySelector(siteConfig.resultsContainerQuery) ||
|
||||
getPossibleElementByQuerySelector([userConfig.prependQuery]) ||
|
||||
getPossibleElementByQuerySelector([userConfig.appendQuery])
|
||||
if (e) {
|
||||
console.log(`SiteAdapters Retry ${i}/${retry}: found`)
|
||||
console.log(e)
|
||||
break
|
||||
} else {
|
||||
console.log(`SiteAdapters Retry ${i}/${retry}: not found`)
|
||||
if (i === retry) return
|
||||
else await new Promise((r) => setTimeout(r, 500))
|
||||
}
|
||||
}
|
||||
document.querySelectorAll('.chatgptbox-container').forEach((e) => {
|
||||
unmountComponentAtNode(e)
|
||||
e.remove()
|
||||
|
||||
@@ -44,8 +44,6 @@ export default {
|
||||
subtitleContent += subtitleData.substring(0, subtitleData.indexOf('<')) + ','
|
||||
}
|
||||
|
||||
await new Promise((r) => setTimeout(r, 1000))
|
||||
|
||||
return cropText(
|
||||
`Provide a brief summary of the video using concise language and incorporating the video title.` +
|
||||
`The video title is:"${title}".The subtitle content is as follows:\n${subtitleContent}`,
|
||||
|
||||
Reference in New Issue
Block a user