XKit-Rewritten icon indicating copy to clipboard operation
XKit-Rewritten copied to clipboard

Standardize text preference processing

Open enchanted-sword opened this issue 1 year ago • 1 comments

Description

Standardizes all preferences using text inputs to ignore case and strip hashtags. Currently, Hide Avatars, Show Originals, and Themed Posts do not ignore case, and Quick Reblog, Tag Replacer, Painter, and Cleanfeed ignore case and strip hashtags.

Resolves #1188 and #982

enchanted-sword avatar Aug 21 '23 01:08 enchanted-sword

Currently, case sensitivity is standardized, but I haven't handled stripping hashtags yet. For that, I imagine an event listener will have to be added to render_scripts.js that replaces hashtag characters in the input area on input, similar to how Quick Reblog and Quick Tags replace quotes with smart quotes as mentioned in #982, something like:

...
const stripTags = ({ target }) => {
  const { value } = target.value;
  target.value = value.replace(/#/g, '');
};
...
const renderPreferences = async function ({ scriptName, preferences, preferenceList }) {
...
 switch (preference.type) {
      ...
      case 'textarea':
        ...
        preferenceInput.addEventListener('input', stripTags);
        break;
      ...
    }
...
};

enchanted-sword avatar Aug 21 '23 02:08 enchanted-sword