Steam web chat scroller

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

当前为 2016-06-28 提交的版本,查看 最新版本

  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.2
  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.disconnect();
  16. observer.observe(node.querySelector('.chat_dialog_content_inner'), {
  17. childList: true
  18. });
  19. } else if (node.classList.contains('chat_message')) {
  20. node.scrollIntoView(true);
  21. }
  22. });
  23. });
  24. });
  25.  
  26. observer.observe(document.querySelector('#chatlog'), {
  27. childList: true
  28. });