UserScripts icon indicating copy to clipboard operation
UserScripts copied to clipboard

Make Magic Editor easily / user-extendible?

Open iBug opened this issue 6 years ago • 5 comments

I took a brief look at Magic Editor's code and found that it's based on a truckload of regexes.

I use that on Android Enthusiasts frequently, but one thing I'm having is that those regexes don't cover WhatsApp, which comes rather often on AE.

While it's possible that I just add a regex for that specific one, I would also like it if it's easily extendible, without modifying existing code. For example, SE AutoComments provides a way to customize the predefined comments via an arbitrary URL to a JSONP file and loads comments from there. Is it possible to have Magic Editor load extra regexes (and replacements) from user-specified external sources? Or in any other way user-extendible?

iBug avatar Dec 02 '18 10:12 iBug

I've been thinking about adding user-expandability wrt. the substitutions from some time. My opinion is that it would be beneficial. I have not previously considered loading additional substitution rules from a supplied URL, but I can see that it might be useful.

As to WhatsApp, I've added to my version of the development branch, so it will be in the next version. Frankly, I thought it was already in there.

makyen avatar Dec 02 '18 16:12 makyen

Me and Mogsdad did discuss this when we we're originally developing the script, but we dropped it when we realized that you can't store functions in JSON.

Tiny-Giant avatar Dec 08 '18 01:12 Tiny-Giant

@Tiny-Giant What if the addition is only regex/replacement pairs, with no functions involved? I think regex can be stored as text and later processed so this shouldn't be a problem (I'm no JavaScript guy so IDK).

iBug avatar Dec 08 '18 01:12 iBug

There appears to be two different goals here:

  1. Simple additions by users to support their own chosen substitutions.
  2. Fully specifiable substitutions, including everything that's currently possible in the App.edits Object. In other words, everything needed to offload everything in App.edits into some external data structure.

I must admit that I'd been assuming just regex/replacement string pairs. While it would be possible to support functions, that would be more complex and have significant security concerns.

I think that we're getting way ahead of ourselves to be thinking of offloading all of App.edits.

makyen avatar Dec 08 '18 02:12 makyen

Definitely, if it were limited to just regular expressions and plain substitutions, that would be much simpler and completely possible with JSON. I was just commenting as to the problem we ran in to when we were discussing this topic originally that caused us to table the issue at that time.

We had wanted to move the App.edits object to a separate file so that it could be updated independently of the business logic, and reduce the amount of scrolling necessary to get any work done. I agree that doing so would be beyond the scope of this request.

Tiny-Giant avatar Dec 08 '18 02:12 Tiny-Giant