blob: f01dba01d78a5864f0a5c3ece997df92d77d4c65 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
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 escapeYomichanCopy(text) {
var userClipboardSettings = await getClipboardSettings();
var tempSettings = {
enableBackgroundMonitor: false,
enableSearchPageMonitor: false,
autoSearchContent: false,
maximumSearchLength: userClipboardSettings.maximumSearchLength,
};
await setClipboardSettings(tempSettings);
navigator.clipboard.writeText(text);
// execute on next JS event loop
setTimeout(async () => await setClipboardSettings(userClipboardSettings), 0);
}
function rubyHelper(element, reading) {
var out = "";
for (var child of element.childNodes) {
if (reading && child.nodeName != "RT") continue;
if (!reading && child.nodeName == "RT") continue;
out += child.textContent;
}
return out;
}
|