ajayyy / DeArrow

Crowdsourcing better titles and thumbnails on YouTube

Home Page:https://dearrow.ajay.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Move title formatting logic to maze-utils (or a separate library)

netux opened this issue · comments

Hello. I'm working on a plugin to add DeArrow features to Grayjay.
One thing I'd like to do is have the automatic Title Case conversion that the official extension has, ideally using the same algorithm behind it.

While I could take the files under src/titles, change them to be standalone, and compile them along with my plugin; that sounds like a lot of work to maintain, which I'd like to avoid.
I was thinking just having it as a separate module would make my life so much easier, biggest hurdle being updating the library every so often.

If this logic were in maze-utils, I could just install that library, import the relevant files in my code, and - through some tree-shaking magic - hopefully get rid of most of the irrelevant bulk of maze-utils in my built plugin.

One problem is it currently contains language detection logic which uses extension specific APIs, but maybe it would work fine by just checking if typeof chrome != undefined

One problem is it currently contains language detection logic which uses extension specific APIs, but maybe it would work fine by just checking if typeof chrome != undefined

Could probably use something less tied to extension logic. E.g. wrapping all the title helpers in a class that takes in some configuration (language, titleFormatting, shouldCleanEmojis, etc.). If it needs to dynamic, then something like a provider model could work?

class TitleFormatting {
  constructor(
    public language: string | () => string,
    public formatting: TitleFormatting () => TitleFormatting,
    public shouldCleanEmojis: boolean | () => boolean
  ) {}

  ...
}

Glad to see you are onboard with the idea. If it's too low prio, I'd be willing to do this myself.

Oh, I just realized I closed the wrong thing 🤦
Don't code at 1am.