Adding extensions to Lectrote?

As far as I can tell, Lectrote is built using JavaScript with Chromium before being wrapped up as an executable.

I use several extensions for Chrome that are just JavaScript snippets. Is it possible to copy and paste the JavaScript snippets from the extensions into one of the Lectrote files before compiling so that the extension runs on Lectrote?

This is part of my ongoing quest to put a profanity filter on an IF interpreter. I’m especially hoping for a filter for Hugo, but a general one would be even better.

Actually, there’s a node.js package that filters, too: http://www.npmjs.com/package/profanity-filter

Can I just add that to packages.json?

I think I’ve almost figured it out on my own. I just need to know: what function in Hugo.js passes text directly to glk?

No idea, it’s all from code transpiled from C. You’d be better off intercepting it on the Glk side.

I just figured it out! It’s in elkote.min.js that you need to change the javascript; I couldn’t find it by searching lectrote on github since it’s fetched from the Quixe repository.

I used the bad-words npm package, and modified the insert_text_detecting function to be the following:

var Filter = require(‘bad-words’),
filter = new Filter();

function insert_text_detecting(el,val){if(!detect_external_links){el.append(document.createTextNode(filter.clean(val)));return;}
if(detect_external_links==‘match’){if(regex_external_links.test(val)){var ael=$(’’,{‘href’:val,‘class’:‘External’,‘target’:’_blank’});ael.text(val);el.append(ael);return;}}

This is exciting; if I can modify Lectrote in this way, it could help people hack individually packaged lectrote apps.

Although now I’m getting the following error when saving/restoring on Hugo:

“fileref_create_by_prompt: unable to create fileref.”

I removed my changes, and the error is still there. I’m going to see if it’s caused by something else I did (like installing the profanity filter).

Ah, I had the wrong version of Quixe being pulled (I just googled Quixe on github instead of clicking on the link from Lectrote).

Oh, and leo-profanity turned out to be better. So I did npm install leo-profanity, and used this code:

var filter = require(‘leo-profanity’);

function insert_text_detecting(el,val){val = filter.clean(val); if(!detect_external_links){el.append(document.createTextNode(val));return;}
if(detect_external_links==‘match’){if(regex_external_links.test(val)){var ael=$(’’,{‘href’:val,‘class’:‘External’,‘target’:’_blank’});ael.text(val);el.append(ael);return;}}