Skip to content

Commit 0b0ba97

Browse files
committed
fix(block.ts): fix block page button issue
1 parent dec0628 commit 0b0ba97

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

src/content/block.ts

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,24 @@ import * as utils from '../core/utils'
33
import * as message from '../core/message'
44
import $ from 'jquery'
55

6-
const href = $('.block-page a>.block-pre').parent().attr('href')
7-
$('.block-page a>.block-pre').parent().attr('href', '#')
8-
$('.block-page a>.block-pre').parent().click(async () => {
9-
const config = await coreConfig.get()
10-
const hrefHost = utils.getHost(href)
11-
if (config.allowList.indexOf(hrefHost) < 0) {
12-
config.allowList.push(hrefHost)
13-
config.blockList.removeByValue(hrefHost)
14-
coreConfig.set(config).then(() => {
6+
$.ready.then(() => {
7+
const href = $('.block-page a>.block-pre').parent().attr('href')
8+
$('.block-page a>.block-pre').parent().attr('href', '#')
9+
$('.block-page a>.block-pre').parent().click(async () => {
10+
const config = await coreConfig.get()
11+
const hrefHost = utils.getHost(href)
12+
if (config.allowList.indexOf(hrefHost) < 0) {
13+
config.allowList.push(hrefHost)
14+
config.blockList.removeByValue(hrefHost)
15+
coreConfig.set(config).then(() => {
16+
location.href = href
17+
})
18+
} else {
1519
location.href = href
16-
})
17-
} else {
18-
location.href = href
19-
}
20-
})
20+
}
21+
})
2122

22-
const url = $('.block-button').parent().attr('href')
23-
$('.block-button').parent().attr('href', '#')
24-
$('.block-button').parent().attr('target', '')
25-
$('.block-button').parent().click(() => {
26-
message.send('open-tab', url)
23+
const url = $('.block-button').parent().attr('href')
24+
$('.block-button').parent().attr('href', url)
25+
$('.block-button').parent().attr('target', '_blank')
2726
})

0 commit comments

Comments
 (0)