Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.40 KB | None | 0 0
  1. // ==UserScript==
  2. // @name DH2 auto ipmute
  3. // @version 1.0
  4. // @description Makes it less atrocious.
  5. // @author eegos and florb
  6. // @match http://*.diamondhunt.co/game.php
  7. // @match https://*.diamondhunt.co/game.php
  8. // @run-at document-idle
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. // if someone sends AUTOMUTE_MESSAGES or more chat messages within AUTOMUTE_SECONDS seconds, they get automatically muted
  13. const AUTOMUTE_ON = true;
  14. const AUTOMUTE_MESSAGES = 15;
  15. const AUTOMWARN_MESSAGES = 7;
  16. const AUTOMUTE_SECONDS = 4;
  17.  
  18. const NUM_LOADTRIES = 10;
  19. const BANNED_PLAYERS = ["lolw00t","salmeh games","andfritz","lolwatt","aldenrulz","pizda24","darkvetal","trevor365u","higuys","umberhallow","wewlaaddd","fittan","niggers","adolf hitler","bonjii","turtlelord11","799350","bouldr","niglipslol","popzitzz","noobie","j a c o b","creeperking9","willum","3x0tic","not2crispy","mr.opwaffl3z","jacob714","jacob716","jacob746","gasthejews","bajskuk","suckabbc","bogjavel","niggerfucker","scrublord123","jordans","head","nigguz","scottyop","lev","mart lands.","mymineblock","zxcvbnm233","lolw00t2","qwertyuiop12","3x0tic","ttyybb","testtesttest","dyhcgfkrhaka","pppppppp","mymineblock3","mymineblock4","mymineblock2","and more","freefrisbee","mymineblock0","lightning123","mymineblock.","at a school","lolw00t4","miniboma","boom the bea","ssssssssssss","loiw0o0t4123"];
  20.  
  21. // internal stuff. No changes necessary
  22.  
  23. var bodyMarginBottom = 210;
  24.  
  25. (function init(tries) {
  26. 'use strict';
  27.  
  28. // wait for game to load, or abort after x tries
  29. if (tries > 0 && (!window.hasOwnProperty("webSocket") || window.webSocket.readyState !== WebSocket.OPEN || window.firstLoadGame === true)) {
  30. setTimeout(() => {
  31. init(--tries);
  32. }, 200);
  33. return;
  34. } else if(tries <= 0) {
  35. // tough life
  36. return;
  37. }
  38.  
  39. // createFixedStatus();
  40. // moveChat();
  41. if(AUTOMUTE_ON){
  42. initAutoMute();
  43. }
  44. // initSkillBarFix();
  45. })(NUM_LOADTRIES);
  46.  
  47. const SERVER_MESSAGE_CHATTAG = 0; // default
  48. const SERVER_MESSAGE_CHATICON = 0; // default
  49. var messageCount = {};
  50. var origAddToChatBox = addToChatBox;
  51.  
  52. function initAutoMute(){
  53. 'use strict';
  54.  
  55. setInterval(resetMessages, AUTOMUTE_SECONDS * 1000);
  56.  
  57. addToChatBox = function(username, icon, tag, message, isPM) {
  58. origAddToChatBox.apply(this, arguments);
  59.  
  60. if(BANNED_PLAYERS.includes(username)){
  61. muteBanned(username);
  62. }
  63.  
  64. // don't mute yourself
  65. if(username != window.username && !window.mutedPeople.includes(username)){
  66. if(messageCount[username]){
  67. if(++messageCount[username] >= AUTOMUTE_MESSAGES){
  68. mutePlayer(username);
  69. }
  70. } else {
  71. messageCount[username] = 1;
  72. }
  73. }
  74. };
  75. }
  76.  
  77. function resetMessages(){
  78. 'use strict';
  79. messageCount = {};
  80. }
  81.  
  82. function muteBanned(username){
  83. 'use strict';
  84.  
  85.  
  86. document.getElementById("chat-input-text").value = "/pm "+username+" getting around a mute is agaisnt the chat rules. ";
  87. sendChat(document.getElementById('chat-input-text'));
  88. document.getElementById("chat-input-text").value = "/ipmute "+username;
  89. sendChat(document.getElementById('chat-input-text'));
  90. // document.getElementById("chat-input-text").value = "/pm eegos"+username+"muted for getting around a mute";
  91. // sendChat(document.getElementById('chat-input-text'));
  92. // sendBytes("IP_MUTE="+username);
  93.  
  94. }
  95.  
  96. function warnPlayer(username){
  97.  
  98.  
  99. document.getElementById("chat-input-text").value = "/pm "+username+" you are sending a lot of message qucikly. this is spam/flooding and it is against the chat rules. ";
  100. sendChat(document.getElementById('chat-input-text'));
  101.  
  102. }
  103. function mutePlayer(username){
  104. // sendBytes("IP_MUTE="+username);
  105. document.getElementById("chat-input-text").value = "/pm "+username+" you have been muted for flooding. ";
  106. sendChat(document.getElementById('chat-input-text'));
  107. document.getElementById("chat-input-text").value = "/ipmute "+username;
  108. sendChat(document.getElementById('chat-input-text'));
  109. // document.getElementById("chat-input-text").value = "/pm eegos"+username+"muted for flooding";
  110. // sendChat(document.getElementById('chat-input-text'));
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement