-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove unused components chore: tidy up components refactor: store helpers chore: impl store refactor: avatar components refactor: cleanup types refactor: remove mobile sniffing
- Loading branch information
1 parent
d11dc54
commit 11f7c46
Showing
102 changed files
with
1,127 additions
and
1,581 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 10 additions & 23 deletions
33
...es/mask/content-script/site-adaptors/facebook.com/automation/pasteToCommentBoxFacebook.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,20 @@ | ||
import { selectElementContents } from '../../../utils/selectElementContents.js' | ||
import { delay } from '@masknet/kit' | ||
import { isMobileFacebook } from '../utils/isMobile.js' | ||
import type { PostInfo } from '@masknet/plugin-infra/content-script' | ||
import { inputText, pasteText } from '@masknet/injected-script' | ||
import { pasteText } from '@masknet/injected-script' | ||
import { MaskMessages } from '@masknet/shared-base' | ||
|
||
export async function pasteToCommentBoxFacebook(encryptedComment: string, current: PostInfo, dom: HTMLElement | null) { | ||
const fail = () => { | ||
MaskMessages.events.autoPasteFailed.sendToLocal({ text: encryptedComment }) | ||
} | ||
if (isMobileFacebook) { | ||
const root = dom || current.comment?.commentBoxSelector?.evaluate()[0] | ||
if (!root) return fail() | ||
const textarea = root.querySelector('textarea') | ||
if (!textarea) return fail() | ||
textarea.focus() | ||
inputText(encryptedComment) | ||
textarea.dispatchEvent(new CustomEvent('input', { bubbles: true, cancelable: false, composed: true })) | ||
await delay(200) | ||
if (!root.innerText.includes(encryptedComment)) return fail() | ||
} else { | ||
const root = dom || current.rootNode | ||
if (!root) return fail() | ||
const input = root.querySelector<HTMLElement>('[contenteditable] > *') | ||
if (!input) return fail() | ||
selectElementContents(input) | ||
input.focus() | ||
pasteText(encryptedComment) | ||
await delay(200) | ||
if (!root.innerText.includes(encryptedComment)) return fail() | ||
} | ||
const root = dom || current.rootNode | ||
if (!root) return fail() | ||
const input = root.querySelector<HTMLElement>('[contenteditable] > *') | ||
if (!input) return fail() | ||
selectElementContents(input) | ||
input.focus() | ||
pasteText(encryptedComment) | ||
await delay(200) | ||
if (!root.innerText.includes(encryptedComment)) return fail() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.