Steam web chat scroller

Scrolls the message view on new messages in the Steam web chat.

  1. // ==UserScript==
  2. // @name Steam web chat scroller
  3. // @namespace http://sharparam.com/
  4. // @description Scrolls the message view on new messages in the Steam web chat.
  5. // @include https://steamcommunity.com/chat/*
  6. // @version 1.0.3
  7. // @grant none
  8. // @run-at document-end
  9. // ==/UserScript==
  10.  
  11. var observer = new MutationObserver(function (mutations) {
  12. mutations.forEach(function (mutation) {
  13. Array.prototype.forEach.call(mutation.addedNodes, function(node) {
  14. if (node.className == 'chat_dialog') {
  15. observer.observe(node.querySelector('.chat_dialog_content_inner'), {
  16. childList: true
  17. });
  18. } else if (node.classList.contains('chat_message')) {
  19. node.scrollIntoView(true);
  20. }
  21. });
  22. });
  23. });
  24.  
  25. observer.observe(document.querySelector('#chatlog'), {
  26. childList: true
  27. });