block 'drop' in steam.tv

block noob!

当前为 2018-09-12 提交的版本,查看 最新版本

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