Reviews for Janitor AI Scraper
Janitor AI Scraper by Weary Galaxy
3 reviews
- Rated 4 out of 5by Frugd, 25 days agooften exports {{user}} instead of the bot's ai name or {{char}} tag
- Rated 4 out of 5by randombum, 3 months agoHas been of much use. Thanks :) Had an AI fix a bug. Feed it into yours if you feel like it:
### Bug Report
**Title:** Fix for extraction crash (undefined `first_message`) & missing messages on long characters
**The Issues & Causes:**
1. **Extraction Crash:** When a character's definition/first message is extremely long, Janitor AI omits the first message from the network payload to save context. This causes `characterData.first_message` to be `undefined`. When `buildCharacterData` attempts to run `.replace()` on it to scrub the user persona, the extension throws a `TypeError` and crashes.
2. **Leftover Tags:** The persona scrubber currently only removes ``, but Janitor AI sometimes uses ``, leaving the tag in the extracted card.
**The Fixes (in `content_script.js`):**
**1. Add a DOM fallback for the missing first message:**
```javascript
// Add above buildCharacterData:
function getFallbackFirstMessage() {
const sliderContainer = document.querySelector(CONFIG.BOT_CHOICES_SLIDER_SELECTOR);
if (sliderContainer) {
const firstLi = sliderContainer.querySelector('li[class*="_messageDisplayWrapper_"]');
if (firstLi) return extractChatMessageContent(firstLi);
}
const wrappers = getPrimaryChatMessageWrappers();
const firstBotWrapper = wrappers.find(msgWrapper => !!msgWrapper.querySelector(CONFIG.CHARACTER_ICON_SELECTOR));
return firstBotWrapper ? extractChatMessageContent(firstBotWrapper) : null;
}
```
**2. Update `buildCharacterData` to use the fallback, safe `.replace()` calls, and handle both tag types:**
```javascript
// Inside buildCharacterData(rawContent):
let effectiveFirstMessage = STATE.firstMessage || getFallbackFirstMessage();
// ... [existing data parsing] ...
if (STATE.userPersonaName && STATE.userPersonaName.trim() !== '') {
// 1. Target both tag types
characterData.description = (characterData.description || '').replace(/<(?:PersonaName|UserPersona)>.*?<\/(?:PersonaName|UserPersona)>/gi, '');
// ... [existing tag stripping] ...
// 2. Add safe fallbacks (|| '') to prevent TypeErrors
characterData.description = (characterData.description || '').replace(personaNameRegex, '{{user}}');
characterData.scenario = (characterData.scenario || '').replace(personaNameRegex, '{{user}}');
characterData.first_message = (characterData.first_message || '').replace(personaNameRegex, '{{user}}');
characterData.mes_example = (characterData.mes_example || '').replace(personaNameRegex, '{{user}}');
if (Array.isArray(characterData.alternate_greetings)) {
characterData.alternate_greetings = characterData.alternate_greetings.map(g => (g || '').replace(personaNameRegex, '{{user}}'));
}
}
```
***