@@ -48,35 +48,27 @@ QVector<Command> predefinedCommands()
4848 c->icon = QString (QChar (IconCircleExclamation));
4949 c->cmd = R"( function hasEmptyOrSingleCharText() {
5050 if (dataFormats().includes(mimeText)) {
51- var text = str(data(mimeText));
52- if (text.match( /^\s*.?\s*$/)) {
51+ const text = str(data(mimeText));
52+ if (/^\s*.?\s*$/.test(text )) {
5353 serverLog('Ignoring text with single or no character');
5454 return true;
5555 }
5656 }
5757 return false;
5858}
5959
60- var onClipboardChanged_ = onClipboardChanged;
61- onClipboardChanged = function() {
62- if (!hasEmptyOrSingleCharText()) {
63- onClipboardChanged_();
64- }
65- }
66-
67- var synchronizeFromSelection_ = synchronizeFromSelection;
68- synchronizeFromSelection = function() {
69- if (!hasEmptyOrSingleCharText()) {
70- synchronizeFromSelection_();
60+ function overrideFunction(fn) {
61+ const oldFn = global[fn];
62+ global[fn] = function() {
63+ if (!hasEmptyOrSingleCharText()) {
64+ oldFn();
65+ }
7166 }
7267}
7368
74- var synchronizeToSelection_ = synchronizeToSelection;
75- synchronizeToSelection = function() {
76- if (!hasEmptyOrSingleCharText()) {
77- synchronizeToSelection_();
78- }
79- }
69+ overrideFunction('onClipboardChanged');
70+ overrideFunction('provideClipboard');
71+ overrideFunction('provideSelection');
8072 )" ;
8173 c->isScript = true ;
8274
0 commit comments