Embed Javascript in a Note

A really nice feature of Devonthink is that on an HTML page you can embed Javascript inside a noteo - it makes for a “programmable note” if you will.

Are there any dedicated Notes apps which have a similar feature?

Is there a reason to do this?

There are lots of ways it could be useful

One very simple example would be to create a template that lets me enter the Pubmed ID or DOI for an academic reference and then have the abstract and other citation metadata retrieved for the note and then I could add whatever I wanted to manually add

I could think of a billion other uses

This can be done with Devonthink but it there is no direct way to share the resulting note; ideal woudld be an app which allows sharing of the resulting Note

I suppose I could do this on my Synology web server (or any other web host) by using a static web page as a “note” which I can then share as a web page - but I was wondering if any dedicated Notes app (with typical tagging and other features expected for Notes) exists that supports embedded Javascript in this fashion

Interesting. Though it feels a bit fragile. If DEVONtech changes their handling of HTML (as they have done in the past with the related Formatted Note format) … boom!

I’d prefer to add the scripting to Typinator, so that it applies to wherever the expansion is applied. Similarly this could be done with KM.

I played with this in DEVONthink for a while but couldn’t get it to do everything I wanted. (Naturally, my use case was needlessly complex…)

Obsidian’s Templater community plugin can execute arbitrary javascript—and can interact with pretty much every aspect of the app and your data. People have been using it to build what are effectively mini-plugins. Here’s the showcase: Discussions · SilentVoid13/Templater · GitHub

2 Likes

Ransomware springs to mind immediately, but I’m sure there are other kinds of malware too :wink:

1 Like

Typinator is interesting - you are suggesting rather than a template, just have a Macro assignment to do it. That may work. I think Textexpander also does Javascript.

If I use KM how do I get the output into some other note? Save to Clipboard?

That sounds perfect for what I had in mind - I may need to get back into Obsidian and explore further. Huge thanks.

1 Like

Thinking about this more - Typinator is a great idea, but Textexapander may be even better since it syncs to iOS - and the Javascript expansion is supported on iOS.

That said - Templater on Obsidian also seems like a terrific idea.

So I will explore both options more - thanks to @anon41602260 and @ryanjamurphy

1 Like

I am still looking into the above options… but I also stumbled upon Nimbus Note - which seems to be a very worthy competitor to Notion, Evernote, Coda, and to some extent Obsidian. It also has some interesting features for small companies such as the ability to have a client portal.

Most notably (and admittedly only in the paid Teams version) it has explicit support for Javascript injection inside a note - I do not think I have seen this before in any other app:

2 Likes

Yes sir.

Yes, you could do that. For example I have a KM macro that run an AppleScript (could have been Javascript) which reaches out to several APIs using JSON Helper to grab data and insert it into a markdown-formated daily note. The note content is put onto the clipboard for pasting, but I could have written the macro to just paste it directly into the location where the cursor was sitting.

(Anyone who scripts should grab JSON Helper.)

1 Like

Thanks - JSON Helper looks interesting

Yet another option - closer to my initial inquiry in fact

I did not realize that Roam Research has built-in Javascript support

Interesting brief YouTube demo here:

And info here: