diff --git a/changelog.md b/changelog.md index 02a98d76..e22fae1c 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,16 @@ # UnderScript Changelog +## Version 0.41.0 (2020-10-12) +### New Features +1. Reload Cards menu item +### Fixes +1. Load storage more reliably +1. Don't show "turn start" twice +1. Load card name from storage +### Misc. +1. Changed @everyone to @underscript +1. Updated for next patch + ## Version 0.40.0 (2020-08-31) ### New Features 1. First/Last page shortcut now works on every valid webpage @@ -9,6 +20,7 @@ 1. Settings -> Library -> Merge Shiny Cards Note: When these filter settings are applied, the rarity icons are semi-transparent (making them look darker) + ## Version 0.39.2 1. Fixed battle log being inconsistent on game finish for players/spectators 1. Fixed some internal bugs diff --git a/src/base/chat/autocomplete.js b/src/base/chat/autocomplete.js index 825ce35f..0da799a9 100644 --- a/src/base/chat/autocomplete.js +++ b/src/base/chat/autocomplete.js @@ -155,7 +155,7 @@ wrap(function setup() { } function add(name, list) { - if (name === global('selfUsername')) return; + if (!list || name === global('selfUsername')) return; const slot = list.indexOf(name); if (slot > -1) list.splice(slot, 1); list.push(name); diff --git a/src/base/chat/toast.js b/src/base/chat/toast.js index 66e88ce4..11a4db5f 100644 --- a/src/base/chat/toast.js +++ b/src/base/chat/toast.js @@ -22,8 +22,9 @@ wrap(() => { if (shouldIgnore(msg, true)) return; if (!msg.message.toLowerCase().includes(`@${global('selfUsername').toLowerCase()}`) && !fn.pingRegex().test(msg.message)) return; const avatar = !settings.value('chatAvatarsDisabled') ? `` : ''; + const chatNames = global('chatNames', { throws: false }); fn.toast({ - title: `${avatar}${fn.user.name(msg.user)} (${chatRoomNames[data.room]})`, + title: `${avatar}${fn.user.name(msg.user)} (${chatRoomNames[data.room] || chatNames && chatNames[data.idRoom] ? $.i18n(chatNames[data.idRoom]) : data.idRoom || 'UNKNOWN'})`, text: msg.message, }); }); diff --git a/src/hooks/chat.js b/src/hooks/chat.js index b348039b..d7a7bedc 100644 --- a/src/hooks/chat.js +++ b/src/hooks/chat.js @@ -16,6 +16,12 @@ eventManager.on(':loaded', () => { } if (eventManager.cancelable.emit(`preChat:${action}`, data).canceled) return; oHandler(event); + if (action === 'getMessage' && data.idRoom) { // For new chat. + data.room = `chat-public-${data.idRoom}`; + data.open = global('openPublicChats').includes(data.idRoom); + } else { + data.open = true; // Just assume it's open for old chat + } eventManager.emit('ChatMessage', data); eventManager.emit(`Chat:${action}`, data); @@ -23,6 +29,21 @@ eventManager.on(':loaded', () => { eventManager.singleton.emit('Chat:Connected'); } }; + // Simulate old getHistory + globalSet('appendChat', function appendChat(idRoom = '', chatMessages = [], isPrivate = true) { + const room = `chat-${isPrivate ? 'private' : 'public'}-${idRoom}`; + const newRoom = !document.querySelector(`#${room}`); + this.super(idRoom, chatMessages, isPrivate); + if (newRoom) { + eventManager.emit('Chat:getHistory', { + room, + roomName: isPrivate ? '' : global('chatNames')[idRoom] || idRoom, + history: JSON.stringify(chatMessages), // TODO: Stop stringify + }); + } + }, { + throws: false, + }); eventManager.on('Chat:getHistory', ({ room, roomName: name }) => { // Send text hook const messages = $(`#${room} .chat-messages`);