I'm new to keyboard maestro and have usually used it for simple macros or custom shortcuts.
Recently, I found this chrome extension which allows you to link to a text fragment on a web page-- Link to Text Fragment + Long article about this here -- which I think would be ridiculously useful for my research needs if I can find a way to paste in the text fragment itself instead of the html code which is what it does at present
So to give more detail, in the github repo for the extension where I raised the same question, a developer sums up what the extension does right now as follows:
Say you select text fragment "worthwhile thing" on https://example.com, right-click and choose "copy link to text". Currently (prior to @tomayac's change), this would copy https://example.com#:~:text=worthwhile%20thing to the clipboard; when loaded, it highlights "worthwhile thing" on the page.
In order for it to do what I'd like, this is what they'll have to do to the extension
The change above means that now we'll also copy some additional data so clients that support HTML paste (e.g. Google Docs, Microsoft Word) will directly paste a link to https://example.com#:~:text=worthwhile%20thing but whose text is "worthwhile thing".
Rather than modify the extension, is there something that Keyboard maestro could do for the second part?
Hey @ccstone sorry for that. It seems that the terms to express what I'm aiming for isn't easy to come by. Just in case I miss again, please also take a moment to look at the repository for this extension where you'll find me asking the same question (it took awhile, but i think they got it)
So to respond to your request for clarification
I want to be able copy the "underlying" link to a selected text fragment and paste it anywhere that supports rich text as a rich text link
So for instance... I used the "link to text fragment" extension right now to copy a link to the first line of your reply to me "Im not quite clear on what you want." The extension however generated a link which when pasted in (not keyboard maestro forum) looks like this:
If you click on this link... it will take you directly to the first line of your response
What I want to do is maintain everything BUT the text displayed.
So although the underlying link is the above, I want the pasted text to be identical to the "surface" text I copied... In other words, when copying "I'm not quite clear..." I want the pasted text to read "I'm not quite clear...
As per your other questions
Chrome and Vivaldi - the extension works on both
Web apps that support rich text links like Workflowy
Yes I'm aware of that. But since 7/10 times I normally paste the text blob into my note taking app and do my notetaking as a nested bullet underneath, I felt it's better to read through a blob of text as opposed to taking the risk of clickiing on the link and then finding myself sucked into this vortex called the internet
This was actually going to be my second request!--- which should help for the remaining 3/10 times when I just need some kind of ref pin
All in all -- accomplishing something like this in tandem with the existing deep linking capabilities I've recently discovered for ebooks (calibre) and PDFs (via Hook) means it's possible at last to link to something and have that link take me directly to the linked section in a page
He found (as @zendude has) that Chrome creates a link of selected text and that that link created in Chrome also works in Safari. The format of the link is the web URL followed by #:~:text= followed by the text you want highlighted with %20 replacing the spaces.
The Shortcut receives input from Quick Actions -- in this case, the text selected in the Safari window. But rather than find a way to use KM to get that text and feed it to the Shortcut, you should be able to do the whole thing in KM. Something like: