SO-Close-Vote-Reviewers / UserScripts

Various user scripts that add features to the review queue or to the chat room
Other
57 stars 41 forks source link

Make Magic Editor easily / user-extendible? #143

Open iBug opened 5 years ago

iBug commented 5 years ago

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?

makyen commented 5 years ago

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.

Tiny-Giant commented 5 years ago

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.

iBug commented 5 years ago

@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).

makyen commented 5 years ago

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.

Tiny-Giant commented 5 years ago

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.