honestbleeps / Reddit-Enhancement-Suite

Reddit Enhancement Suite
http://redditenhancementsuite.com
GNU General Public License v3.0
4.15k stars 879 forks source link

User Tagger x filteReddit: custom conditions to display user tags #4881

Open jewel-andraia opened 6 years ago

jewel-andraia commented 6 years ago

A potential overblown design for @aslakhol's https://github.com/honestbleeps/Reddit-Enhancement-Suite/issues/4722#issuecomment-429592085

Summary

Use the "post/comment filters" engine to determine if a user tag should be displayed. Add/alter UI entry points to set filters for user tags.

Use cases

Implementation details

  1. Apply filtering to usertags (medium-hard)
    1. Add "filter" data to "user tag" data model
    2. When rendering user tag UI, run filter logic to determine whether to show user tag or button
  2. Add "post ID" to filter cases (medium-easy)
    1. may as well add "comment id" while you're there
  3. Alter "highlight" button (from user info hover card) to create a "Highlighted" user tag
    1. Set user tag text to a flag emoji or something
    2. Set filter to "post id: this comments page" when browsing comments or "subreddit: this subreddit" when browsing subreddit
    3. Set filter to "before this date": today + 1 week
  4. Add option to User Tagger to apply user tag's color to author using User Highlighter
larsjohnsen commented 5 years ago

The filtering stage would be relative straight forward. I'm thinking:

In userHightlight.js, add a storage containing values like these:

{
  [username]: {
    hightlightColor: 'red',
    conditions: { type: 'group', op: 'any', of: [
        /* list of browseContext conditions */
        { type: 'subreddit', patt: 'foo' },
        { type: 'subreddit', patt: 'bar' },
      ] }
  }
}

and in module.beforeLoad generate CSS:

for (const ([username, { highlightColor }] of Object.entries(highlightStorage.get()) {
  if (await Case.fromConditions(conditions).evaluate())
    highlightUser(username, highlightColor)

conditions can be set by a builder interface like is done in filteReddit/LineFilter.js, i.e. caseBuilder.drawBuilderBlock(startConditions, browseCases)