Obsidian+PR Cookbook - 𝕏 - YouTube - Official Obsidian Docs
A common thing that you want to do in Obsidian, especially when starting out, is to search Obsidian’s community plugins to see if there a plugin to help you with your current task. In practice this is a few clicks away: you have to open the settings, find community plugins, click the tab, then go to the search box. What would be cool would be to have a keybinding to jump straight to search.
How to code this up
Writing Obsidian plugins is interesting, plugins start off very “API’y” by defining callbacks using Obsidian API but then when you start defining a user interface they can turn into website coding using JavaScript, HTML and the document object model. I’ve found that sometimes to automate things, I almost start doing “screen scraping” because there is no API for what I want to do.
This is what I had to do to implement this, but I did have to do that much screen scraping - just find a browse button a click it. Here is custom command in Plugin REPL will open the Community plugins settings page and then find the button with “Browse” written in and click it. (Note that I’m the author of Plugin REPL)
newCommand(async function open_community_plugins() {
await openSetting("Community plugins")
document.evaluate('//button[text()="Browse"]', app.setting.containerEl).iterateNext().click()
})
This uses the document.evaluate method of the standard JavaScript document object model.
Once you’ve written this command you can evaluate it with Plugin REPL and optionally add it to your repl.md startup file.
Demo
The old fashioned Templater way
You don’t have to use Plugin REPL for this - although it makes things easy if you do. Instead you could use Templater by creating the following plugin in your template directory called plugins.
<%*
tp.app.setting.open()
await tp.app.setting.open()
await tp.app.setting.openTabById(tp.app.setting.settingTabs.filter((tab) => tab.name === "Community plugins")[0].id)
document.evaluate('//button[text()="Browse"]', app.setting.containerEl).iterateNext().click()
%>
You can then add this template as a command under Template hotkeys in Templater’s settings.
And then define a hotkey for the Insert command. This approach is a bit more effort to debug (Templater doesn’t give particularly useful error output). Also Templater does not really support assignment - hence the inlining of tp.app.setting.openTabById(tp.app.setting.settingTabs.filter((tab) => tab.name === "Community plugins")[0].id).
But it does work!
P.S You could also use Quickadd to add a script (which does not have the limitations that Templater has) - also templater supports user script. Both approaches involve using another editor and a fair amount of clicking.
Finishing up
I hope you found that useful. I enjoy using this keybinding and it makes installing plugins more fun. If you found this page interesting you might like read.
This page about some useful hotkeys I used in Obsidian (including this one)
This page about automated maps of content using dataview
This kind of academic summary of note taking in Obsidian that I made
Also you can follow me on X or substack if you like.
Interesting? The is a whole “Cookbook” here of similar Obsidian tricks. Also I am creating tool in Obsidian, some of it for automated reading. If you are interested maybe check out the blog.
I am not affiliated with Obsidian. I am the author of Plugin REPL