微信防撤回

将撤回的消息保留并提示"[拦截到一条撤回的消息]"

  1. // ==UserScript==
  2. // @name 微信防撤回
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0.0.1008
  5. // @description 将撤回的消息保留并提示"[拦截到一条撤回的消息]"
  6. // @author nkxyz
  7. // @match *://wx.qq.com/*
  8. // @match *://wx2.qq.com/*
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. function modifyResponse(response) {
  14.  
  15. var original_response, modified_response;
  16. if (this.readyState === 4) {
  17. if (this.requestURL && this.requestURL.indexOf("mmwebwx-bin/webwxsync") > 0 && this.requestMethod === "POST") {
  18. original_response = response.target.responseText;
  19. // try{
  20. modified_response = JSON.parse(original_response);
  21. //console.log(modified_response)
  22. if(modified_response.AddMsgList && modified_response.AddMsgList.length > 0){
  23. for (var i = 0; i < modified_response.AddMsgCount; i++) {
  24. var msgType = modified_response.AddMsgList[i].MsgType;
  25. var info = modified_response.AddMsgList[i];
  26. var modified = false;
  27. if ( msgType === 10002){
  28. modified_response.AddMsgList[i].MsgType = 1;
  29. var cdataBegin = modified_response.AddMsgList[i].Content.indexOf("![CDATA[");
  30. var cdataEnd = -1;
  31. if (cdataBegin != -1) {
  32. cdataEnd = modified_response.AddMsgList[i].Content.indexOf("]", cdataBegin);
  33. }
  34. if (cdataEnd != -1) {
  35. modified_response.AddMsgList[i].Content = "<p><span>"+ modified_response.AddMsgList[i].Content.substr(cdataBegin+7, cdataEnd + 1 - cdataBegin - 7) +"</span></p>";
  36. } else {
  37. modified_response.AddMsgList[i].Content = "<p><span>[拦截到一条撤回的消息]</span></p>";
  38. }
  39. modified = true;
  40. }
  41. }
  42. if (modified) {
  43. Object.defineProperty(this, "response", {writable: true});
  44. modified_response = JSON.stringify(modified_response);
  45. this.response = modified_response;
  46. }
  47. }
  48. // }catch(e){
  49. // this.responseText = original_response
  50. // }
  51. }
  52.  
  53. }
  54. }
  55.  
  56. function openBypass(original_function) {
  57.  
  58. return function(method, url, async) {
  59. // 保存请求相关参数
  60. this.requestMethod = method;
  61. this.requestURL = url;
  62.  
  63. this.addEventListener("readystatechange", modifyResponse);
  64. return original_function.apply(this, arguments);
  65. };
  66.  
  67. }
  68.  
  69. function sendBypass(original_function) {
  70. return function(data) {
  71. // 保存请求相关参数
  72. this.requestData = data;
  73. return original_function.apply(this, arguments);
  74. };
  75. }
  76.  
  77. XMLHttpRequest.prototype.open = openBypass(XMLHttpRequest.prototype.open);
  78. //XMLHttpRequest.prototype.send = sendBypass(XMLHttpRequest.prototype.send);
  79.  

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址