aboutsummaryrefslogtreecommitdiff
path: root/yomichan
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-12-31 12:47:27 +0100
committerlonkaars <loek@pipeframe.xyz>2022-12-31 12:47:27 +0100
commitb49925b09a8962411706b00a446f5cd84007a086 (patch)
tree71ace362fca94afb99e7f36792cc0a9391de2698 /yomichan
parent410189aa43291d7409c58c5c4901dcb746ff9fff (diff)
temporarily turn off clipboard monitor on sentence export
Diffstat (limited to 'yomichan')
-rw-r--r--yomichan/sentence-export.js34
1 files changed, 33 insertions, 1 deletions
diff --git a/yomichan/sentence-export.js b/yomichan/sentence-export.js
index e38f001..3b2a476 100644
--- a/yomichan/sentence-export.js
+++ b/yomichan/sentence-export.js
@@ -1,4 +1,22 @@
-function exportSentence() {
+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 = "";
@@ -14,7 +32,21 @@ 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);
+
return output;
}