intfiction.org

The Interactive Fiction Community Forum
It is currently Sun Dec 17, 2017 10:48 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Thu Oct 26, 2017 5:33 pm 
Offline

Joined: Tue Jul 28, 2015 1:05 pm
Posts: 1009
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.

_________________
-My IFDB name is Mathbrush.

Anyone can make interactive fiction; if you've made a game and need a review on IFDB, let me know!


Top
 Profile Send private message  
Reply with quote  
PostPosted: Thu Oct 26, 2017 5:46 pm 
Offline

Joined: Tue Jul 28, 2015 1:05 pm
Posts: 1009
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?

_________________
-My IFDB name is Mathbrush.

Anyone can make interactive fiction; if you've made a game and need a review on IFDB, let me know!


Top
 Profile Send private message  
Reply with quote  
PostPosted: Thu Oct 26, 2017 10:35 pm 
Offline

Joined: Tue Jul 28, 2015 1:05 pm
Posts: 1009
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?

_________________
-My IFDB name is Mathbrush.

Anyone can make interactive fiction; if you've made a game and need a review on IFDB, let me know!


Top
 Profile Send private message  
Reply with quote  
PostPosted: Fri Oct 27, 2017 12:13 am 
Offline
User avatar

Joined: Wed Oct 14, 2009 4:02 am
Posts: 2436
No idea, it's all from code transpiled from C. You'd be better off intercepting it on the Glk side.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Fri Oct 27, 2017 12:25 am 
Offline

Joined: Tue Jul 28, 2015 1:05 pm
Posts: 1009
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=$('<a>',{'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.

_________________
-My IFDB name is Mathbrush.

Anyone can make interactive fiction; if you've made a game and need a review on IFDB, let me know!


Top
 Profile Send private message  
Reply with quote  
PostPosted: Fri Oct 27, 2017 12:27 am 
Offline

Joined: Tue Jul 28, 2015 1:05 pm
Posts: 1009
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).

_________________
-My IFDB name is Mathbrush.

Anyone can make interactive fiction; if you've made a game and need a review on IFDB, let me know!


Top
 Profile Send private message  
Reply with quote  
PostPosted: Fri Oct 27, 2017 12:30 am 
Offline

Joined: Tue Jul 28, 2015 1:05 pm
Posts: 1009
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=$('<a>',{'href':val,'class':'External','target':'_blank'});ael.text(val);el.append(ael);return;}}

_________________
-My IFDB name is Mathbrush.

Anyone can make interactive fiction; if you've made a game and need a review on IFDB, let me know!


Top
 Profile Send private message  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group