钉钉web版防撤回、屏蔽已读

本文介绍了如何改造钉钉Web版以实现消息防撤回和已读屏蔽功能。通过拦截并修改网页钉钉的JS代码,阻止撤回消息和已读确认的发送,从而达到保留消息和隐藏已读状态的目的。改造涉及对`sendMsg`和`dispatchMsg`函数的拦截,并针对特定消息类型进行处理。
摘要由CSDN通过智能技术生成

钉钉web版防撤回、屏蔽已读

改造后,程序下载地址:

https://gitee.com/demos-proj/cef-sharp-demo63.0.3/attach_files/795697/download/DingDingWeb.7z

原理

1. 说明

网页钉钉地址

https://im.dingtalk.com/

app.js文件

https://g.alicdn.com/DingTalkWeb/web/3.8.10/assets/app.js

钉钉关键代码

// 接收加密消息
_onMessage: function(e) {
    try {
        var t = JSON.parse(e.data)
        } catch (t) {
            return void this.localLog.error("WKSDK: ", this.name + " parse json error :" + e.data)
        }
    ...
}
// 解密消息
i.prototype.dispatchMsg = function(e) {
    var t = this
    , n = e.map(function(e) {
        return function() {
            var e = this.dataItem.objectType
            , n = null;
            try {
                // n 为解密后的消息对象
                n = r.decodeFromB64(this.dataItem.data),
                    m[e] ? n = m[e](n) : d.error("can't decode sync data, object type: ", e)
            } catch (e) {
                return d.error("decode sync data error", n, e),
                    Promise.resolve()
            }
        }
    }
	...
}
// 发送消息
// e为类型,n为参数
// /r/IDLMessageStatus/updateToView
// /r/IDLMessageStatus/updateToRead
// /r/IDLSend/send
sendMsg: function(e, t, n, i) {
            var o = new r(e,t,n,i);
            if (this.state === a.OPENED || this.state === a.REGED || this.state === a.SUBSCRIBED) {
                if ("/reg" === e)
                    return this._send(o.msgEntity) ? (this._addPending(o),
                this.state === a.OPENED && (o.canSendBeforeAuth() ? (this.waitingRegMsgs.push(o),
            } else
                this.state === a.CLOSED || this.state === a.INITED ? (o.sendOfflineMsg()
            return o
        },

2. 消息类型

objectTypedata
1000文本、表情、图片、文件、视频、点赞、名片、收藏
1002删除消息
1001撤回消息
1003附加消息-详细
1005附加消息-简版

3. 改造

3.1 发送、接收消息拦截

在消息发送、接收处,输出日志

 sendMsg: function(e, t, n, i) {
     /******拦截发送消息******/
     console.log("【发送消息】" + JSON.stringify(e) + "\r\n" + JSON.stringify(n));
     //debugger;
     /*********************/
     var o = new r(e,t,n,i);
     if (this.state === a.OPENED || this.state === a.REGED || this.state === a.SUBSCRIBED) {
     }
 }
i.prototype.dispatchMsg = function(e) {
        var t = this
          , n = e.map(function(e) {
            return function() {
                var e = this.dataItem.objectType
                  , n = null;
                try {
                    n = r.decodeFromB64(this.dataItem.data),
                    m[e] ? n = m[e](n) : d.error("can't decode sync data, object type: ", e)
                    /******拦截接收消息******/
                    console.log("【接收消息】" + JSON.stringify(e) + "\r\n" + JSON.stringify(n));
     				//debugger;
                    /*********************/
                    debugger;
                } catch (e) {
                    return d.error("decode sync data error", n, e),
                    Promise.resolve()
                }
                
    }

3.2 防撤回

在消息接收处,拦截撤回消息

i.prototype.dispatchMsg = function(e) {
        var t = this
          , n = e.map(function(e) {
            return function() {
                var e = this.dataItem.objectType
                  , n = null;
                try {
                    n = r.decodeFromB64(this.dataItem.data),
                    m[e] ? n = m[e](n) : d.error("can't decode sync data, object type: ", e)
                    /******防撤回******/
                    if(e == 1001)
                    {
                    	console.log("【防撤回】" + JSON.stringify(e) + "\r\n" + JSON.stringify(n));
                        return;
                    }
                    /*********************/
                } catch (e) {
                    return d.error("decode sync data error", n, e),
                    Promise.resolve()
                }
                
    }

3.3 屏蔽已读

在消息发送处,拦截已读相关消息发送

 sendMsg: function(e, t, n, i) {
     /******屏蔽已读******/
     if(e == "/r/IDLMessageStatus/updateToView" ||
       e == "/r/IDLMessageStatus/updateToRead")
     {
         console.log("【屏蔽已读】" + JSON.stringify(e) + "\r\n" + JSON.stringify(n));
         return;
     }
     /*********************/
     var o = new r(e,t,n,i);
     if (this.state === a.OPENED || this.state === a.REGED || this.state === a.SUBSCRIBED) {
     }
 }
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值