Hide Spam Messages

Hides messages from a specific user list on willyoupressthebutton.com

当前为 2022-09-20 提交的版本,查看 最新版本

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