Skip to content

Commit 0c33d19

Browse files
committed
Merge branch 'release/1.10.6' into released
2 parents 19dabac + b0f26f8 commit 0c33d19

File tree

4 files changed

+36
-9
lines changed

4 files changed

+36
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "maskbook",
33
"license": "AGPL-3.0-or-later",
4-
"version": "1.10.5",
4+
"version": "1.10.6",
55
"private": true,
66
"engines": {
77
"node": ">=13.2.0"

src/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "http://json.schemastore.org/chrome-manifest",
33
"name": "Maskbook",
4-
"version": "1.10.5",
4+
"version": "1.10.6",
55
"manifest_version": 2,
66
"web_accessible_resources": ["*.css", "*.js", "*.jpg", "*.png"],
77
"permissions": ["storage", "downloads", "webNavigation", "activeTab"],

src/social-network-provider/twitter.com/encoding.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ export const twitterEncoding = {
6060
])}`,
6161
payloadDecoder: (text: string) => {
6262
const links: { raw: string; protocol: string; encoded: string }[] = anchorme(text, { list: true })
63-
let links_ = links.filter(x => x.raw.endsWith('%40'))[0]?.raw
63+
let links_ = links
64+
.map(l => ({
65+
...l,
66+
raw: l.raw.replace(/$/, ''),
67+
}))
68+
.filter(x => x.raw.endsWith('%40'))[0]?.raw
6469
try {
6570
links_ = new URL(links_).pathname
6671
.slice(1)

src/social-network-provider/twitter.com/utils/fetch.ts

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,18 @@ import Services from '../../../extension/service'
1414
* handle: "MisakaMirror"
1515
* }
1616
*/
17-
const parseNameArea = (t: string) => {
18-
const r = regexMatch(t, /((.+\s*)*)@(.+)/, null)!
17+
const parseNameArea = (nameArea: string) => {
18+
const result = regexMatch(nameArea, /([^@]*)@(.+)/, null)
19+
20+
if (!result) {
21+
return {
22+
name: '',
23+
handle: '',
24+
}
25+
}
1926
return {
20-
name: r[1].replace(/\n+/g, ''),
21-
handle: r[3].replace(/\n+/g, ''),
27+
name: result[1].replace(/\n+/g, ''),
28+
handle: result[2].replace(/\n+/g, ''),
2229
}
2330
}
2431

@@ -92,10 +99,25 @@ export const postNameParser = (node: HTMLElement) => {
9299
return parseNameArea(notNullable(node.querySelector<HTMLTableCellElement>('.user-info')).innerText)
93100
} else {
94101
const tweetElement = node.querySelector('[data-testid="tweet"]') ?? node
95-
const nameInNoramlTweet = tweetElement.children[1]?.querySelector<HTMLAnchorElement>('a')?.innerText
102+
const nameInUniqueAnchorTweet =
103+
tweetElement.children[1]?.querySelector<HTMLAnchorElement>('a[aria-haspopup="false"]')?.innerText ?? ''
104+
const nameInDoubleAnchorsTweet = Array.from(
105+
tweetElement.children[1]?.querySelectorAll<HTMLAnchorElement>('a[aria-haspopup="false"]') ?? [],
106+
)
107+
.map(a => a.textContent)
108+
.join('')
96109
const nameInQuoteTweet = tweetElement.children[0]?.querySelector<HTMLDivElement>('[aria-haspopup="false"]')
97110
?.innerText
98-
return parseNameArea(notNullable(nameInNoramlTweet || nameInQuoteTweet))
111+
112+
return (
113+
[nameInUniqueAnchorTweet, nameInDoubleAnchorsTweet, nameInQuoteTweet]
114+
.filter(Boolean)
115+
.map(n => parseNameArea(n!))
116+
.find(r => r.name && r.handle) ?? {
117+
name: '',
118+
handle: '',
119+
}
120+
)
99121
}
100122
}
101123

0 commit comments

Comments
 (0)