Reload & autoscroll buttons at character.ai

Adds menu with autoscrolling, page reloading, char's info, chat styling, replies numbering and bookmarking, imagegen hiding, anyone's last reply deleting, etc.

Author
Mozgovlom
Daily installs
5
Total installs
7,323
Ratings
3 1 0
Version
2.2.2
Created
2023-01-17
Updated
2023-05-12
License
N/A
Applies to

[2024] The script doesn't work for chat2 links, but still partially works for some old chats. No further updates will be provided.


This script adds some quality of life features I wanted to have to continue to pretend to enjoy c.ai even after the countless lobotomies. Made to visually accompany the HearYourWaifu script by Some ukranon 🇺🇦.

Disclaimer 1: I have no actual knowledge of scripting; basically this script is cobbled together from Stackoverflow examples with js-beautifier on top. Disclaimer 2: Since c.ai is getting more wonky with every passing day, I have to stress the fact, that I don't account for many possible things going wrong, which would prevent the script from working as intended. If something doesn't work - refresh the page or close the tab and open another, everything this script does is tab-persistent. Also, most of the features are dependent on the chat being successfully loaded, and this check is timed, so if the chat didn't load for a long time you better refresh the page again to force the script. Disclaimer 3: Since I don't have enough knowledge and\or motivation to make any of the script settings be saved into the GM_* values to prevent them from being wiped in case of the script updates (if that actually is the way to do it), you have to write them down. Because you'll have to input them again after the script update. BACK UP any settings you've changed, any color codes or links you've set inside the script code.

  • Autoscroll fires 1 Arrow-Right if Swipe-next button is present; clicks Try-Again button in case of the error popup with buttons; reloads the page and continues in case of the 500 error popup. Helps to get something good to choose from from the community characters, where you don't need to rate it's answers. Despite my under-the-hood changes to the autoclicking behavior, the "Try Again" button multiclick still happens, and the error gets snowballed into sending many requests to the server. Worst case scenario if you get only errors and it begins spamming them by tens, the server will temporarily ban you (the "You are being rate limited" page) - you won't see any obvious indication of this unless you reload the page or read the browser devtools console, so be aware. To mitigate this, I've added an option (disabled by default) to use a "safe trying again mode"; the downside being that you will have to keep the tab in focus (i.e. open on screen); but this should allow you to use this feature safely. Another option is to disable page reload in case of "500 Internal Server Error" (disabled by default) - if you enable both of these, you should be able to safely use this feature with your own chars, where you'd want to rate every reply (but no guarantees). The intended use is as follows: you send your message to the char, get a first reply from it and then enable the autoscrolling; after it loads all 30(+) replies, disable the autoscrolling, choose the desired reply, send your message and repeat; i.e. get a first reply from char before using this!
  • Reload reloads the page just as the browser button would.
  • Reload & Scroll reloads the page and fires 50 arrow right keypresses to scroll to the end of the replies carousel.
  • Fetch 10 replies sends a request to get 10 replies directly to the server. It doesn't give any indication of success or failure, the only way to see if it's worked is to use browser devtools (or HYW to some extent). The received replies won't be shown until you reload the page, so you'll HAVE to reload the page after you click this button to see the new replies. NB: nowadays c.ai doesn't send a filtered message at all more and more often (the {"abort": true,"error": "No eligible candidates","last_user_msg_id": null} response to the fetch, meaning that HYW log could stay empty when you're trying to "bruteforce" the filter).
  • Delete last reply sends a request to delete last repliy directly to the server. It's mainly intended to be used when you get more than one reply from the char, and it goes not "to the right" but "to the bottom", and then you have to delete your own message losing the first (good) reply of the two as well. Again, it doesn't give any indication of success or failure, so you MUST reload the page after you click this button. To be sure you can open up the browser devtools before clicking and watch the console. These two features inside the "Reply control" submenu are the most likely ones to not work as intended, because the code for them is the one I understand the least.
  • ImageGen hides images, generated by char.
  • Blur blurs names and avatars of you and char. The idea is to make taking "anonymous" screenshots easier (because I don't use similar feature from HYW).
  • Wallpaper sets page background image, there are 2 separate ones for light and dark mode. Replace links inside the script code to set your own images (mine were AI generated so no copyrights). Switch state is persistent for the current tab, and the image is always the same one from the script. But in the submenu you can input a link to the desired image and set it as a tab-specific wallpaper. Be aware, no link validity checks are performed; it's on you to provide a correct image link.
  • Avatars allows to set a custom tab-specific avatars for you and char. No link validity checks are performed; it's on you to provide a correct image link.
  • Chat background enables a solid color background for the chat itself (the infinite-scroll-component). Needed when you use a saturated detailed wallpaper.
  • Chat style sets a style for chat bubbles. Replace the color codes inside the script code to set your own bubble colors, which are separate for light and dark mode. After 09.03.2023 the second style, which was intended to be used with imagegen chars now doesn't look it's best - I might come back to fix it properly, but most likely won't.
  • Switch to enable c.ai native dark mode. Basically is the same switch as in the Profile Settings, so it works for the whole website. This is the only thing that isn't tab-persistent.
  • Char info shows publicly available data about character: name, interaction count (for unlisted and private chars as well), greeting, short description, long description, avatar (full-sized), image prompt (for image generating chars).
  • Inside the script code you can disable the cai's "new feedback" buttons
  • Inside the script code you can disable script's reply numbering under the avatar and replace the color codes of the bookmarking - the glow when you click on these labels (2 separate colors for light and dark mode). After 09.03.2023 this doesn't look as good as it was, but this is as much as I'm willing to do.
  • Inside the script code you can disable script's « and » quickscroll buttons to scroll messages by 5.
  • Inside the script code you can disable script's persistent notification in case of 500 Internal Server Error, hinting you to reload the page. More on this: according to my observations, when you get this error while waiting for the first char reply after your message, you can just close the popup and click the "send" button again without having to delete and resend your message. But when you get this first reply after having closed the popup, all the subsequent replies will go not "to the right" but "to the bottom"! This is why you must reload the page if you get a 500-error, but you do not have to delete your message. And if you get this popup while swiping, firstly you can't get more replies, and secondly if you send your message to any of the already received replies, you won't be able to get any more replies beside the first one in the subsequent roll. In conclusion, imo you have to always reload the page in case of 500-error, but no additional actions are needed.

I use a lot of mutation observers and queryselectoralls, which makes me suspect that the script might have some tab performance impact. But I don't actually notice any, and I didn't verify this, so take this notice as you please. The current appearance of the menu\buttons is shown on the last screenshot. And the menu is supposed to be responsive, meaning it should look good enough on small screens. But the actual autoscrolling is tied to the swipe right\left onscreen buttons, so it won't work on touch-screen devices where these buttons are absent. Regarding the @match rule. You may change it to https://beta.character.ai/chat* if you're using the urlparams and they change the link (e.g. if you're opening a chat from saved chats). This will also make the menu appear in rooms. But be aware, that it isn't intended to be used in rooms, is untested, and some features obviously won't work, although some might.

Note to self: at some point in summer parent_msg_id was replaced with parent_msg_uuid but my fetch still works anyway. Broken: darkmode switch; char blur; chat style #3; chat background; reply numbering for a new row (still works for the current row on page reload), also numbers go away when old replies are loaded by scrolling up - don't think I'll be able to counter that without storing the bookmarked states in local storage, which is possible but meh. Something is wrong with message height when imagegen, don't know what to look at if I get to it. Chats athttps://beta.character.ai/chat2? where c.ai tests new frontend require rewriting most\everything so it'll be a separate script, if ever. Currently it's possible to just remove 2 from the link to use old chat where the script works.