How to start a javascript file from this plugin? #308
-
I have a javascript file that counts words in quotes. According to various threads I should be able to launch a How can I launch a .js file from this plugin? This is on Linux Mint, btw. Thanks! It probably helps if This is the script: https://forum.obsidian.md/t/best-way-to-count-words-in-quotes/50507/7?u=readerguy42 It counts the words in quotes and pops out a little window with that info. Is this possible to do via the plugin? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hi, thank you for your question. I took a look at the script you are trying to evaluate with Node.js. // get all cm-lines in active tab
var lineText = document.querySelectorAll(".workspace-leaf.mod-active .cm-content .cm-line"); This code should be evaluated in Obsidian app, but your approach to launch a separate Node.js process would evaluate the JS code outside Obsidian. It seems that Node.js does not have a If you want to use the code, it's better to use the JavaScript Init plugin like was suggested in the forum thread you linked. Then the code will run in the context of Obsidian. The same behavior could be achieved with SC, too, but the script would need to be edited so that it would not use |
Beta Was this translation helpful? Give feedback.
-
Concerning your other question in #306Quote from @ReaderGuy42 in #306:
Sorry, I don't know Even if I find it, it might be that it does not solve your problem, but could at least try. |
Beta Was this translation helpful? Give feedback.
Hi,
thank you for your question. I took a look at the script you are trying to evaluate with Node.js.
This code should be evaluated in Obsidian app, but your approach to launch a separate Node.js process would evaluate the JS code outside Obsidian. It seems that Node.js does not have a
document
object itself, which is why you are getting the error messageReference error: document is not defined...
. But even ifdocument
would be present, the code would still not work outside Obsidian, because it would not have access to the content structure of Obsidian.If you wa…