27

Screenshot / Code Snippet

chat room signatures with pronouns

About

It's hard to miss these days - the Code of Conduct is about to change. It will emphasize the importance of using the correct pronoun when referring to a user in third person. This most often comes up in chat, and some users already have information about which pronouns to use in the 'about' field in their chat profile, especially when that is not already clear from their username and/or avatar. Version 2.0 of the script performs the same feat on Q&A pages, but uses the Q&A profile instead.

In the Teachers' Lounge, an idea was proposed to pull that information from the user profile into the chatroom itself through a userscript. Stack Exchange Chat hasn't received updates in quite a while, so this idea isn't likely to be implemented soon. A userscript like this is the next best thing.

Installation / configuration

It's a userscript which means you need a userscript manager installed in your browser if you don't have one already. Just Google for Violentmonkey or Tampermonkey, how to install them depends on your browser.

The script itself can be installed via this link; source code can be found here.

After installation, you can reload this very page and check my usercard to verify if the script has been installed:

usercard with 'Script successfully installed' message

To edit your chat profile to add your own pronouns, go to chat, click your username in the top bar and then the edit link for the 'about' field:
chat profile with edit link
Editing your Q&A profile works similarly, but you can also click this link, change your profile and click "Save and copy changes to all public communities".

The script looks (case-insensitive) for the following ways of specifying pronouns:

  • A link to Pronoun Island, e.g. 'http://my.pronoun.is/he'
  • An explicit specification starting with 'Pronouns:' and ending with a period, newline, or just the end of the text, e.g. 'Pronouns: they/them.'
  • Pronouns joined by forward slashes, e.g. 'she/her'; a full list of supported pronouns can be found here which is sourced from Pronoun Island. If your pronouns aren't in the list, feel free to mention them here or make a pull request. Do note that some of the pronouns listed here are likely to yield false positives because they're specialized terminology (e.g. vi/vim).

Platform

Tested with Violentmonkey in Firefox and Tampermonkey in Chrome on macOS, but it's likely to work on all browsers and platforms. (Please let me know if it doesn't!)

Contact

Post a comment or answer here, or create an issue/pull request on GitHub.

  • 2
    Love the idea of this tool! I had already added my pronouns via a link to pronoun.is in my 'about' ("Clearly a dragon. my.pronoun.is/she ") a little while ago. Might it be an idea to add functionality to support that link specifically? – Elva Oct 3 at 14:33
  • Thank you, that's a good idea (I think somebody mentioned it in chat as well), I'll have a look. – Glorfindel Oct 3 at 14:38
  • 1
    For those of us using GreaseMonkey, we can replace GM_addStyle with greasemonkey.win-start.de/patterns/add-css.html and we'll need to add an @require for jquery. – Matt Ellen Oct 3 at 15:23
  • @Elva this is now supported in v1.1. I did notice that when I click on such a link (added by the script) in chat, it disappears. I'm working on that ... – Glorfindel Oct 3 at 20:45
  • @MattEllen I'd expect GreaseMonkey to support GM_addStyle; it does start with GM. If you have any idea how to fix it while keeping the script cross-user-manager-compatible, I'd really appreciate it. – Glorfindel Oct 3 at 20:47
  • @glorfindel apparently the latest version of greasemonkey removed that function 🤷‍♂️ that's all the wiki says. I can have a look over the weekend. The thing I linked to might be cross browser compatibile – Matt Ellen Oct 3 at 21:43
  • 1
    @Glorfindel When I click the "script can be installed via" link, Chrome tells me "Apps, extensions, and user scripts cannot be added from this website". Any suggestions? (and sorry if this is a novice question...) – LarrySnyder610 Oct 4 at 0:51
  • 1
    @LarrySnyder610 you'd have to install a userscript manager first, like Tampermonkey or Violentmonkey. Most people coming here are familiar with userscripts and how they work, but it's definitely an oversight on my part and I'll update the installation instructions. Thank you! – Glorfindel Oct 4 at 6:56
  • @Glorfindel awesome, that worked, thanks! – LarrySnyder610 Oct 4 at 13:23
  • I downloaded this just now, it's my first userscript. On Firefox Mac with Tampermonkey, this doesn't seem to change anything—can I see a screenshot of what parts of the page should change? – Stormblessed Oct 5 at 3:39
  • Oh they just weren't formatted right. – Stormblessed Oct 5 at 3:44
  • Could you tell me what you mean by 'not formatted right'? Do you have a screenshot? – Glorfindel Oct 5 at 8:01
  • I'd suggested this on another post and was finally told this was a thing. Upvoted! – PB Supports Monica Oct 10 at 19:33
  • Assuming I haven't misunderstood, there's quite a few unincluded pronouns. But I guess the Pronouns: <text> mitigates that? – user51156 Oct 12 at 13:14
  • 1
    It makes lookups to every chat user / Q&A user on that page. So your profiles influence how other users with the script view your usercard. I now realize that's a lot of calls on a Q&A page, which tend to get loaded quite often (contrary to a chatroom, the only place where v1 of the script was active). I'll probably build some additional caching this week. – Glorfindel Oct 14 at 18:18
8

Can you implement some kind of support for those of us who are fine with any pronoun, i.e., have no preference?

I realise I could probably write something like

don’t/care

into my profile, but that would be weird for those who visit my profile and are not aware of this script.

  • 2
    This is now supported in v1.1: you could write e.g. 'Pronouns: whatever you prefer.' – Glorfindel Oct 3 at 20:44
7

/

Strip out the http://my.pronoun.is/ portion of the pronoun tag under the username, seeing as how you can't click on it anyway.

  • 1
    You're right, something has to be done about this (and there's already somebody who submitted a pull request on this topic). My preference would be to have a clickable, well formatted link to the site. – Glorfindel Oct 15 at 7:04
  • Fixed in v2.3, in chat the link is stripped (since I couldn't make nested <a> elements work), in Q&A the link is make clickable. – Glorfindel Oct 18 at 7:44
4

Seems like there are similar requests for users' info on Chat.SO that fails due to CORS-blocking. You might want to disable the script for Chat.SO so we don't make unneccessary requests that fail, or implement a workaround using GM_xmlhttpRequest.

Workaround I made: https://github.com/samliew/SO-mod-userscripts/blob/master/lib/common.js#L41

  • oh wait, just dynamically set the location.hostname, and don't hard-code to chat.stackexchange.com – Samuel Liew Oct 4 at 11:07
  • I realized this as well, I always make mistakes like this. chat.stackexchange.com is hardcoded ... – Glorfindel Oct 4 at 11:07
  • @Glorfindel want me to make a patch? – Samuel Liew Oct 4 at 11:08
  • 1
    This is now fixed in v1.2. – Glorfindel Oct 4 at 11:16
3

Can this be made to work on the transcript? It doesn't, currently.

Pronoun doesn't show on transcript

  • 2
    I considered that, but I'm not sure if it's really useful. You need somebody's pronouns when you want to post a message, and that can only be done in the room itself, so the Pronoun Assistant will activate by then. – Glorfindel Oct 5 at 8:00
3

Clicking the name of someone in chat breaks the userscript (pronouns no longer appear). To make it more generic, DOM updated to chat, and to main sites (.post-layout, comments, etc.) break the userscript.

  • Fixed in v2.3 of the script. Somehow, it didn't occur in the Teachers' Lounge, but I was able to reproduce it in another chatroom. – Glorfindel Oct 18 at 7:44
1
// If we're on a Q&A site, also cache all changes to the `users` object to save on API calls

Can I purge this cache manually, e.g. after changing the About me entry and/or is there an automatic expiration period? (I implemented such in my user flair once [but it didn't work in FF then]).

  • 1
    Good question. My original idea was to cache them for an hour or so, but I can't see any expiration in ArtOfCode's code (he wrote that part). I'll ping him. – Glorfindel Oct 20 at 13:05
  • 2
    There's no automatic expiration, no - I didn't think of that. I'll see if that can be added. For now, if you run delete localStorage.stackPronounAssistant_users in your browser console, that should purge the cache. – ArtOfCode Oct 20 at 18:16
0

Referring to v2.7 of the script the @matches and @includes can be adapted to:

// @include /^https:\/\/(\w*\.+)?(stack|ask|code|server|super|math)\w*\.(com|net)\/questions\/?.*$/
// Matches:             |<none> ||      ⬑– Domains that don't follow |  | TLDs  || Paths        |
//                      | meta. ||      the <something>.stackexchange|           | + possible   |
//                      |       ||      scheme...                    |           |   fragment   |
//                      |⬑–––––––⬑–––– ...and those that do.        |

// @exclude /^https:\/\/(\w*\.+)?(stack|ask|code|server|super|math)\w*\.(com|net)\/questions\/ask\/?.*$/
// Matches:             |<none> ||      ⬑– Domains that don't follow |  | TLDs  || Path              |
//                      | meta. ||      the <something>.stackexchange|           |+ possible fragment|
//                      |       ||      scheme...                    |
//                      |⬑–––––––⬑–––– ...and those that do.        |
//              ---- extend bracket expression(s) above for new site(s) ----

Such:

  • the script's meta data are way shorter (well, apart from the comments, but still :),
  • it is activated on SE main Q&A domains and meta and chat sub-domains,
  • @excludes do work on .../ask pages on sites that don't follow the <something>.stackexchange.<TLD> scheme, too (which don't work for those, atm),
  • it can be easily adapted for new domains by extending the bracket expression(s).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .