Skip to content

Commit 9550518

Browse files
authored
Merge pull request #32 from cloudoptlab/fix/2.x/bookmark-search-on-baidu
fix(bookmark.ts): fix the bookmark container issue on baidu result pages
2 parents 18bce08 + f8fafc6 commit 9550518

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/content/bookmark.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,20 @@ class BookmarkSearch {
1414
if (this.host.endsWith('.baidu.com')) {
1515
this.getKeyword = () => ($('#kw')[0]['value'] as string)
1616
this.innerClass = '#content_left'
17+
let interval = null
1718
$('#kw').bind('input propertychange', () => {
18-
this.sendSearch(this.getKeyword())
19+
// Have to wait for the container to appear
20+
if (interval !== null) {
21+
clearInterval(interval)
22+
interval = null
23+
}
24+
interval = setInterval(() => {
25+
if ($(this.innerClass).length > 0) {
26+
clearInterval(interval)
27+
interval = null
28+
this.sendSearch(this.getKeyword())
29+
}
30+
}, 100)
1931
})
2032
} else if (this.host.startsWith('www.google.')) {
2133
this.getKeyword = () => ($('input.gsfi')[0]['value'] as string)

0 commit comments

Comments
 (0)