Hide Spam Messages

Hides messages from a specific user list on willyoupressthebutton.com

  1. // ==UserScript==
  2. // @name Hide Spam Messages
  3. // @namespace https://greasyfork.org/en/users/945115
  4. // @version 0.2
  5. // @description Hides messages from a specific user list on willyoupressthebutton.com
  6. // @author Unmatched Bracket
  7. // @match *://www.willyoupressthebutton.com/*
  8. // @match *://willyoupressthebutton.com/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=willyoupressthebutton.com
  10. // @grant none
  11. // @license The Unlicence
  12. // ==/UserScript==
  13.  
  14. var oldSend = XMLHttpRequest.prototype.send
  15. var oldOpen = XMLHttpRequest.prototype.open
  16.  
  17. // Block list. Messages from these usernames will be hidden.
  18. const block_list = [
  19. "This_is_legal", // pure spam
  20. "SweetCandy98", // inaproppriate spamming
  21. ]
  22.  
  23. XMLHttpRequest.prototype.open = function(_, url) {
  24. if (url.includes("api/comments/get")) {
  25. this.doInject = true
  26. }
  27. oldOpen.call(this, ...arguments)
  28. }
  29.  
  30. XMLHttpRequest.prototype.send = function() {
  31. if (this.doInject) {
  32. var oldReadyChange = this.onreadystatechange
  33. this.onreadystatechange = function () {
  34. //console.log(this.readyState, this.status, this.responseType)
  35. if (this.readyState == 4) {
  36. console.log(this.response)
  37. var respJson = JSON.parse(this.response)
  38. respJson.injected = true
  39. respJson.data = respJson.data.filter((comment) => {
  40. return !comment.user || !block_list.includes(comment.user.name)
  41. })
  42.  
  43. var newText = JSON.stringify(respJson)
  44. var newResp = () => {
  45. return newText
  46. }
  47. this.__defineGetter__("responseText", newResp)
  48. this.__defineGetter__("response", newResp)
  49. }
  50. oldReadyChange.call(this, "debug text")
  51. }
  52. }
  53. oldSend.call(this)
  54. }