diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-01-29 22:29:48 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-01-29 22:29:48 +0100 |
commit | 97b6e373ba2f654dadd9c299c09098879de964fc (patch) | |
tree | e0af41a66b133470394e34085dda61a21268ef1f /yomichan-user/conf.d/sentence-export.js | |
parent | 2f74b3659b3aac4bd9bccee705f1b972a5332f4d (diff) |
add copy button for copying word to custom card template
Diffstat (limited to 'yomichan-user/conf.d/sentence-export.js')
-rw-r--r-- | yomichan-user/conf.d/sentence-export.js | 38 |
1 files changed, 3 insertions, 35 deletions
diff --git a/yomichan-user/conf.d/sentence-export.js b/yomichan-user/conf.d/sentence-export.js index f15d890..176cdcd 100644 --- a/yomichan-user/conf.d/sentence-export.js +++ b/yomichan-user/conf.d/sentence-export.js @@ -1,21 +1,3 @@ -async function getClipboardSettings() { - return (await yomichan.api.getSettings([{ - scope: "profile", - optionsContext: { current: true }, - path: 'clipboard' - }]))[0].result; -} - -async function setClipboardSettings(settings) { - await yomichan.api.modifySettings([{ - scope: "profile", - optionsContext: { current: true }, - path: 'clipboard', - action: 'set', - value: settings - }]); -} - async function exportSentence() { var inputHTML = document.getElementById("query-parser-content"); var output = ""; @@ -42,19 +24,7 @@ async function exportSentence() { } } - var userClipboardSettings = await getClipboardSettings(); - var tempSettings = { - enableBackgroundMonitor: false, - enableSearchPageMonitor: false, - autoSearchContent: false, - maximumSearchLength: userClipboardSettings.maximumSearchLength, - }; - await setClipboardSettings(tempSettings); - - navigator.clipboard.writeText(output); - - // execute on next JS event loop - setTimeout(async () => await setClipboardSettings(userClipboardSettings), 0); + escapeYomichanCopy(output); return output; } @@ -72,13 +42,11 @@ function patchSearchBar() { searchBarOuter.insertBefore(button, searchBarOuter.childNodes[2]); } -function run() { +(() => { if (document.body.classList.contains("patched")) return; patchSearchBar(); document.body.classList.add("patched"); -} - -run(); +})(); |