Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/util/Injected/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,30 @@
exports.LoadUtils = () => {
window.WWebJS = {};

// Newer WA Web builds (2.3000.1043xxx+) no longer expose `_serialized` on a
// MsgKey; the same string is only reachable through `toString()`. Every
// page-side `Msg.get(key._serialized)` then looks messages up by `undefined`.
// Restore it as a prototype getter. The setter keeps builds that still assign
// `_serialized` in the constructor working: it stores an own property, which
// shadows the getter exactly as before.
const MsgKeyProto = window.require('WAWebMsgKey').prototype;
if (!Object.getOwnPropertyDescriptor(MsgKeyProto, '_serialized')) {
Object.defineProperty(MsgKeyProto, '_serialized', {
get() {
return this.toString();
},
set(value) {
Object.defineProperty(this, '_serialized', {
value,
writable: true,
enumerable: true,
configurable: true,
});
},
configurable: true,
});
}

/**
* Helper function that compares between two WWeb versions. Its purpose is to help the developer to choose the correct code implementation depending on the comparison value and the WWeb version.
* @param {string} lOperand The left operand for the WWeb version string to compare with
Expand Down
Loading