block 'drop' in steam.tv

block noob!

  1. // ==UserScript==
  2. // @name block 'drop' in steam.tv
  3. // @version 1.4.1
  4. // @description block noob!
  5. // @author xz
  6. // @include *://steam.tv/*
  7. // @grant none
  8. // @namespace https://greasyfork.org/users/48754
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13. //auto report spam user, maybe steam will ban u
  14. var AutoReport=false;
  15.  
  16. var lastMessage={};
  17.  
  18. if(typeof CBroadcastChat !== 'undefined'){
  19. console.log("script has loaded! AutoReport is "+(AutoReport?"on":"off"));
  20. CBroadcastChat.prototype.DisplayChatMessage = function( strPersonaName, bInGame, steamID, strMessage, bLocal )
  21. {
  22. var _chat = this;
  23. if(lastMessage[steamID]===strMessage||strMessage.search(/^!|drop$|box$|(\w)\1{4,}|^(\u02d0.*?\u02d0)\2{4,}|^\u02d0(\w)*\u02d0$|^.$|tradeoffer\/new/i)>-1){
  24. console.log("%s(%s)\t\t%s%s",steamID,strPersonaName,strMessage,lastMessage[steamID]===strMessage?"(Multiple identical messages)":"");
  25. if ( AutoReport && !this.m_mapMutedUsers[steamID])
  26. //this.MuteUserForSession(steamID,strPersonaName);
  27. {
  28. this.m_mapMutedUsers[steamID] = strPersonaName;
  29. var rgParams =
  30. {
  31. chat_id: this.m_ulChatID,
  32. user_steamid: steamID,
  33. muted: 1
  34. };
  35. this.m_webapi.ExecJSONP( 'IBroadcastService', 'MuteBroadcastChatUser', rgParams, true, null, 15 )
  36. .done( function()
  37. {
  38. return 0;
  39. })
  40. .fail( function()
  41. {
  42. if (bOwner)
  43. {
  44. console.log('Failed to mute %s. Please try again.'.replace( /%s/, strPersonaName ) );
  45. delete _chat.m_mapMutedUsers[steamID];
  46. return 0;
  47. }
  48. });
  49. console.log("auto reported user: "+this.GetMutedUsers().length);
  50. return 0;
  51. }else{
  52. return 0;
  53. }
  54. //console.log(this.IsUserMutedLocally(steamID));
  55. }
  56. lastMessage[steamID]=strMessage;
  57. var elMessage = $J('#ChatMessageTemplate').clone();
  58. elMessage.attr( 'id', '' );
  59. elMessage.attr( 'data-steamid', steamID );
  60.  
  61. var elChatName = $J( '.tmplChatName', elMessage );
  62. elChatName.text(strPersonaName);
  63. elChatName.attr( 'href', 'https://steamcommunity.com/profiles/' + steamID );
  64. elChatName.attr( 'data-miniprofile', 's' + steamID );
  65.  
  66. if ( steamID == this.m_broadcastSteamID )
  67. elMessage.addClass( 'Broadcaster' );
  68.  
  69. var elText = $J( '.tmplChatMessage', elMessage ).text(strMessage);
  70.  
  71. var strHTML = elText.html();
  72. strHTML = this.AddEmoticons(strHTML, steamID, bLocal);
  73. strHTML = this.AddLinks(strHTML);
  74.  
  75. elText.html(strHTML);
  76.  
  77. elMessage.show();
  78.  
  79. var bAutoScroll = this.BAutoScroll();
  80. $J('#ChatMessages').append(elMessage);
  81.  
  82. // if text is too long, add expand button
  83. var elText = $J( '.tmplChatMessage', elMessage );
  84. if ( elText.height() > elMessage[0].clientHeight )
  85. {
  86. var elExpand = $J( '<div class="ChatExpand">+</div>' );
  87. elMessage.append(elExpand);
  88. elExpand.on('click', function () { _chat.ExpandMessage(elMessage) } );
  89. }
  90.  
  91. if (bAutoScroll)
  92. this.ScrollToBottom();
  93. };
  94. }
  95. })();