diff --git a/libs/acf/util/src/lib/value.ts b/libs/acf/util/src/lib/value.ts index df9bf1b8..cab53d76 100644 --- a/libs/acf/util/src/lib/value.ts +++ b/libs/acf/util/src/lib/value.ts @@ -1,5 +1,7 @@ import RandExp from 'randexp'; +const LOCAL_STORAGE_COPY = 'auto-clicker-copy'; + declare global { interface Window { __batchRepeat: number; @@ -16,6 +18,8 @@ export const VALUE_MATCHER = { BATCH_REPEAT: //, ACTION_REPEAT: //, SESSION_COUNT: //, + CLIPBOARD_PASTE: //, + PASTE: //, }; export const Value = (() => { @@ -51,6 +55,17 @@ export const Value = (() => { return value; }; + const getClipboardPaste = async (value: string): Promise => { + const clipText = await navigator.clipboard.readText(); + return value.replaceAll('', clipText); + }; + + const getPaste = (value: string): string => { + const copyContent = localStorage.getItem(LOCAL_STORAGE_COPY); + if (copyContent) return value.replaceAll('', copyContent); + return value; + }; + const getValue = async (value: string): Promise => { /// For select box value is boolean true if (typeof value !== 'string') { @@ -75,6 +90,12 @@ export const Value = (() => { if (VALUE_MATCHER.API.test(value)) { value = getApiValue(value); } + if (VALUE_MATCHER.CLIPBOARD_PASTE.test(value)) { + value = await getClipboardPaste(value); + } + if (VALUE_MATCHER.PASTE.test(value)) { + value = getPaste(value); + } return value; };