Skip to content

Commit 73e96d2

Browse files
committed
Merge branch 'fix/1.5.1' into released
2 parents a0ad6a2 + ad8d9f7 commit 73e96d2

File tree

6 files changed

+17
-12
lines changed

6 files changed

+17
-12
lines changed

Diff for: src/components/DataSource/PeopleRef.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ import { PersonIdentifier, GroupIdentifier } from '../../database/type'
77
import { useValueRef } from '../../utils/hooks/useValueRef'
88

99
const ref = new ValueRef<Person[]>([])
10-
Services.People.queryPeople('facebook.com').then(p => (ref.value = p))
10+
function hasFingerprint(x: Person) {
11+
return !!x.fingerprint
12+
}
13+
Services.People.queryPeople('facebook.com').then(p => (ref.value = p.filter(hasFingerprint)))
1114
MessageCenter.on('newPerson', person => {
1215
person.groups.forEach(group => Object.setPrototypeOf(group, GroupIdentifier.prototype))
1316
person.previousIdentifiers &&
1417
person.previousIdentifiers.forEach(id => Object.setPrototypeOf(id, PersonIdentifier.prototype))
1518
Object.setPrototypeOf(person.identifier, PersonIdentifier.prototype)
1619
const old = ref.value.filter(x => !x.identifier.equals(person.identifier))
17-
ref.value = [...old, person]
20+
ref.value = [...old, person].filter(hasFingerprint)
1821
})
1922
export function usePeople() {
2023
return useValueRef(ref)

Diff for: src/components/InjectedComponents/PostComments.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ interface Props {
3030
export function PostComment({ comment, postContent, postIV, needZip }: Props) {
3131
return (
3232
<AsyncComponent
33-
promise={() => Services.Crypto.decryptComment(postIV, postContent, comment)}
33+
promise={() => {
34+
if (!postIV || !postContent) return Promise.resolve('')
35+
return Services.Crypto.decryptComment(postIV, postContent, comment)
36+
}}
3437
dependencies={[postIV, postContent, comment]}
3538
awaitingComponent={null}
3639
completeComponent={result =>

Diff for: src/extension/content-script/injections/MyUsername.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export function getPersonIdentifierAtFacebook(links: link[] | link, allowCollect
9090
}
9191
return PersonIdentifier.unknown
9292
}
93-
function getUserID(x: string) {
93+
export function getUserID(x: string) {
9494
if (!x) return null
9595
const relative = !x.startsWith('https://') && !x.startsWith('http://')
9696
const url = relative ? new URL(x, location.host) : new URL(x)
@@ -101,5 +101,5 @@ function getUserID(x: string) {
101101
const search = new URLSearchParams(url.search)
102102
return search.get('id')
103103
}
104-
return url.pathname.replace(/^\//, '')
104+
return url.pathname.replace(/^\//, '').replace(/\/$/, '')
105105
}

Diff for: src/extension/content-script/injections/Posts.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ new MutationObserverWatcher(posts)
109109
selectElementContents(_root.querySelector('[contenteditable]')!)
110110
dispatchCustomEvents('paste', encryptedComment)
111111
await sleep(200)
112-
if (_root.innerText.match(encryptedComment)) console.log('Okay')
112+
if (_root.innerText.match(encryptedComment)) 'Okay'
113113
else prompt('Please paste it into the comment box!', encryptedComment)
114114
}}
115115
/>

Diff for: src/extension/content-script/injections/Posts/PostInspector.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export function PostInspector(props: PostInspectorProps) {
2828
encryptedPost: deconstructPayload(post),
2929
provePost: post.match(/🔒(.+)🔒/)!,
3030
}
31+
if (type.provePost) Services.People.uploadProvePostUrl(new PostIdentifier(postBy, postId))
3132
useAsync(() => {
3233
if (!whoAmI.equals(postBy)) return Promise.resolve([])
3334
if (!type.encryptedPost) return Promise.resolve([])
@@ -63,7 +64,6 @@ export function PostInspector(props: PostInspectorProps) {
6364
</>
6465
)
6566
} else if (type.provePost) {
66-
Services.People.uploadProvePostUrl(new PostIdentifier(postBy, postId))
6767
return <AddToKeyStore postBy={postBy} provePost={post} />
6868
}
6969
return null

Diff for: src/extension/content-script/injections/ProfilePage.tsx

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
import Services from '../../service'
22
import { PersonIdentifier } from '../../../database/type'
33
import { LiveSelector, MutationObserverWatcher } from '@holoflows/kit/es'
4+
import { getUserID } from './MyUsername'
45

56
//#region Find key from bio
67
{
78
const bio = new LiveSelector().querySelector<HTMLDivElement>('#profile_timeline_intro_card')
89
function tryFindBioKey(text: string) {
910
const a = document.querySelector<HTMLAnchorElement>('#fb-timeline-cover-name a')
1011
if (!text || !a) return
11-
const id = a.href.match(/profile\.php\?id=(.+)/)
12-
const name = a.href.match(/^https:..\.facebook.com\/(.+)/)
13-
if (!id && !name) return
14-
const username = id ? id[1] : name![1]
15-
Services.Crypto.verifyOthersProve(text, new PersonIdentifier('facebook.com', username))
12+
const id = getUserID(a.href)
13+
if (!id) return
14+
Services.Crypto.verifyOthersProve(text, new PersonIdentifier('facebook.com', id))
1615
}
1716
new MutationObserverWatcher(bio)
1817
.enableSingleMode()

0 commit comments

Comments
 (0)