Skip to content

Commit 19d5fbd

Browse files
committed
Merge branch 'hotfix/1.10.18' into released
2 parents 41656a3 + 3acde26 commit 19d5fbd

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "maskbook",
3-
"version": "1.10.16",
3+
"version": "1.10.18",
44
"private": true,
55
"license": "AGPL-3.0-or-later",
66
"scripts": {

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.16",
4+
"version": "1.10.18",
55
"manifest_version": 2,
66
"web_accessible_resources": ["*.css", "*.js", "*.jpg", "*.png"],
77
"permissions": ["storage", "downloads", "webNavigation", "activeTab"],

src/social-network-provider/facebook.com/tasks/pasteIntoPostBox.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,17 @@ export async function pasteIntoPostBoxFacebook(
7878
const [element] = activated.evaluate()
7979
element.focus()
8080
await sleep(100)
81-
if ('value' in document.activeElement!) dispatchCustomEvents('input', text)
82-
else dispatchCustomEvents('paste', text)
83-
element.dispatchEvent(new CustomEvent('input', { bubbles: true, cancelable: false, composed: true }))
81+
// HACK: the is workaround
82+
// https://github.com/eraeco/party.lol/blob/f63ae89b0b339b52aac12f65eb7a0865e522530a/content.js#L102
83+
element.querySelector('br')?.replaceWith(document.createTextNode(text))
84+
onToggleInput(element)
8485
await sleep(400)
8586
if (isMobileFacebook) {
8687
const e = document.querySelector<HTMLDivElement | HTMLTextAreaElement>('.mentions-placeholder')
8788
if (e) e.style.display = 'none'
8889
}
8990
// Prevent Custom Paste failed, this will cause service not available to user.
90-
if (element.innerText.indexOf(text) === -1 && 'value' in element && element.value.indexOf(text) === -1) {
91+
if (!(element.innerText.includes(text) || ('value' in element && element.value.includes(text)))) {
9192
copyFailed()
9293
}
9394
} catch {
@@ -99,3 +100,18 @@ export async function pasteIntoPostBoxFacebook(
99100
prompt(warningText, text)
100101
}
101102
}
103+
104+
function onToggleInput(element: Element) {
105+
try {
106+
const init = { bubbles: true, cancelable: true }
107+
for (const name of ['input', 'change']) {
108+
element.dispatchEvent(new Event(name, init))
109+
}
110+
for (const name of ['keydown', 'keypress', 'keyup']) {
111+
element.dispatchEvent(new KeyboardEvent(name, init))
112+
}
113+
} catch {
114+
return false
115+
}
116+
return true
117+
}

0 commit comments

Comments
 (0)