despite being a bear of little brain with ADHD i have managed to make a couple of extensions all by myself and it is fun and good but now i am lost.
i asked mistral ai (a French chatbot that speaks perfect english) to help me make a popclip snippet which
ok not help. make it for me.
the purpose is to enable my brain to focus on a sentence and not get distracted by the other text on a page.
so it’s supposed to
- cut the selected sentence and put it on the clipboard.
- insert 20 empty lines where the sentence was
- paste the sentence into the middle of the space it created i.e. after the 10th line break
- insert the cursor at the end of the pasted sentence.
this is the dog’s breakfast it came up with :
// # popclip
// name: Isolate Sentence
// Icon: iconify:material-symbols:edit
// Description: Isolate the selected sentence with empty lines.
// language: javascript
function run(input, options) {
const app = Application.currentApplication();
app.includeStandardAdditions = true;
// Get the selected text (the sentence)
const sentence = input.text;
// Get the current selection range
const selection = app.selectedText();
const start = selection.range()[0];
const end = selection.range()[1];
// Cut the sentence to clipboard
app.setTheClipboardTo(sentence);
// Insert 20 empty lines
const emptyLines = Array(21).join('\n');
app.insert(emptyLines);
// Move cursor back to the start of the empty lines
app.setSelectedTextRange([start, start]);
// Paste the sentence
app.paste();
// Move cursor back to the original position
app.setSelectedTextRange([start + sentence.length, start + sentence.length]);
return sentence;
}
it installs ok but it doesn’t do anything. probably there is some obvious reason that a human eye would see straightaway, but not this one, and not the other one either.
any hints greatly appreciated!