Skip to content

Commit

Permalink
[twitter] Fix reply auto-input in Twitter
Browse files Browse the repository at this point in the history
  • Loading branch information
nikicat committed Nov 24, 2022
1 parent 19c3eb2 commit 1c8b55c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion extensions/src/webln.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ if (!window.donate4funPageScriptLoaded) {

async function emulateKeypresses(selector, content) {
const element = selector === ':focus' ? document.activeElement : document.querySelector(selector);
// Thanks to https://github.com/keepassxreboot/keepassxc-browser/blob/d7e34662637b869500e8bb6344cdd642c2fb079b/keepassxc-browser/content/keepassxc-browser.js#L659-L663
// This code is here because if call it from content script warnings will occur "Permission denied to access property X". (YouTube overrides event handles and tries to access event attributes)
// This works on Chrome
const dataTransfer = new DataTransfer();
dataTransfer.setData("text/plain", content);
element.dispatchEvent(new ClipboardEvent('paste', { bubbles: true, clipboardData: dataTransfer, data: null }));
// And this works on Firefox
element.dispatchEvent(new InputEvent('beforeinput', {bubbles: true, inputType: "insertText", data: content}));
element.dispatchEvent(new InputEvent('input', {bubbles: true, inputType: "insertText", data: content}));
element.dispatchEvent(new Event('change', {bubbles: true}));
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { readable, writable, get } from 'svelte/store';
import cLog from "$lib/log.js";

export const webOrigin = writable(globalThis.location.origin);
export const isExtension = !globalThis.location.origin.startsWith('http');
Expand Down

0 comments on commit 1c8b55c

Please sign in to comment.