Giter Club home page Giter Club logo

Comments (13)

neo2701 avatar neo2701 commented on June 19, 2024 1
NodeHandler.checkForEditedMessageNode = function (message, messageId, remoteJid) {
  //
  // Check if this is a message edit node
  //
  var messageEditValue = ProtocolMessage.Type.MESSAGE_EDIT.value;

  if (message && message.editedMessage.message.protocolMessage.type == messageEditValue) {
    var editedMessageId = message.editedMessage.message.protocolMessage.key.id;
    if (saveEditedMsgsHookEnabled) {
      onEditedMessageBlocked(message, remoteJid, messageId, editedMessageId);
    }

    return true;
  }

  return false;
};

That function works too, but i can't do the UI.

from whatsapp-web-incognito.

tomer8007 avatar tomer8007 commented on June 19, 2024

Do you mean saving the versions history of edited messages? Adding new features such as this is not so much of my priority right now, unless more people will show demand for them. Maybe in the future

from whatsapp-web-incognito.

neo2701 avatar neo2701 commented on June 19, 2024

Yes, Exactly.
I want to implement it myself but i couldn't found the object of edited message..

from whatsapp-web-incognito.

tomer8007 avatar tomer8007 commented on June 19, 2024

Perhaps they're sending a REVOKE message first just like they do for deleted messages. I assume you have WADebugMode on.

from whatsapp-web-incognito.

neo2701 avatar neo2701 commented on June 19, 2024

They just send this node with message tag

{
    "tag": "message",
    "attrs": {
        "from": "62****:[email protected]",
        "type": "text",
        "edit": "1",
        "id": "3EB07B07BB4AB8459ECF63",
        "sender_lid": "***[email protected]",
        "notify": "Neo",
        "t": "1686930292"
    },
    "content": [
        {
            "tag": "enc",
            "attrs": {
                "v": "2",
                "type": "pkmsg",
                "decrypt-fail": "hide"
            },
            "content": {}
        },
        {
            "tag": "device-identity",
            "content": {}
        }
    ]
}

from whatsapp-web-incognito.

tomer8007 avatar tomer8007 commented on June 19, 2024

Sure, but what does the encrypted protobuf contain?

from whatsapp-web-incognito.

neo2701 avatar neo2701 commented on June 19, 2024

Just found out that the WAProto is very outdated 😂
I tried to update it from Baileys repo but it seems to break some function.

I see new MESSAGE_EDIT protocol on Baileys WAProto

from whatsapp-web-incognito.

neo2701 avatar neo2701 commented on June 19, 2024
{
    "stack": "Error: Failed to execute 'createElement' on 'Document': The tag name provided ('107') is not a valid name.\n    at document.createElement (https://web.whatsapp.com/app.ab3cb96ce8b0b5e2ac7c.js:93:816907)\n    at nodeToElement (chrome-extension://dgnhgkkblbdlgkebhopdhjfnliemgipp/core/utils.js:43:26)\n    at nodeToElement (chrome-extension://dgnhgkkblbdlgkebhopdhjfnliemgipp/core/utils.js:52:29)\n    at nodeToElement (chrome-extension://dgnhgkkblbdlgkebhopdhjfnliemgipp/core/utils.js:52:29)\n    at nodeToElement (chrome-extension://dgnhgkkblbdlgkebhopdhjfnliemgipp/core/utils.js:52:29)\n    at nodeToElement (chrome-extension://dgnhgkkblbdlgkebhopdhjfnliemgipp/core/utils.js:52:29)\n    at printNode (chrome-extension://dgnhgkkblbdlgkebhopdhjfnliemgipp/core/interception.js:439:38)\n    at Object.promise (chrome-extension://dgnhgkkblbdlgkebhopdhjfnliemgipp/core/interception.js:128:13)"
}

How to fix Error on this function?

function nodeToElement(node) {
  if (!node.tag) {
    var element = document.createElement("unknown");
    element.innerHTML = node.toString();
    return element;
  }
  console.log(node.tag);
  if (node.tag == "0") node.tag = "zero"; // prevent "The tag name provided ('0') is not a valid name."
  if (node.tag == "1") node.tag = "one"; // prevent "The tag name provided ('1') is not a valid name."

  var element = document.createElement(node.tag);

  for (var attribute in node.attrs) {
    element.setAttribute(attribute, node.attrs[attribute]);
  }

  if (node.content) {
    if (Array.isArray(node.content)) {
      for (var subNode of node.content) {
        element.appendChild(nodeToElement(subNode));
      }
    } else {
      element.appendChild(nodeToElement(node.content));
    }
  }

  return element;
}

file : /core/utils.js:43:26

from whatsapp-web-incognito.

tomer8007 avatar tomer8007 commented on June 19, 2024

Oh, the if (node.tag == "0") node.tag = "zero" was just a dirtry hack I wrote to make exactly this error go away (numbers can't be tag names).

It'll be better to auto-detect all numbers, but for now you can add if (node.tag == "107") or whatever

I see new MESSAGE_EDIT protocol on Baileys WAProto

Makes perfect sense, I'll update it

from whatsapp-web-incognito.

neo2701 avatar neo2701 commented on June 19, 2024
function numberstowords(number) {
  var units = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"];
  number = number.toString();
  var result = "";
  for (var i = 0; i < number.length; i++) {
    result += units[number[i]];
  }
  return result;
}

function nodeToElement(node) {
  if (!node.tag) {
    var element = document.createElement("unknown");
    element.innerHTML = node.toString();
    return element;
  }
  if (node.tag == "0") node.tag = "zero"; // prevent "The tag name provided ('0') is not a valid name."
  if (node.tag == "1") node.tag = "one"; // prevent "The tag name provided ('1') is not a valid name."
  //   if (node.tag == "107") node.tag = "onezeroseven"; // prevent "The tag name provided ('107') is not a valid name."
  if (isNaN(node.tag) == false) node.tag = numberstowords(node.tag);
  var element = document.createElement(node.tag);

  for (var attribute in node.attrs) {
    element.setAttribute(attribute, node.attrs[attribute]);
  }

  if (node.content) {
    if (Array.isArray(node.content)) {
      for (var subNode of node.content) {
        element.appendChild(nodeToElement(subNode));
      }
    } else {
      element.appendChild(nodeToElement(node.content));
    }
  }

  return element;
}

Hahaha, it works after i did that

from whatsapp-web-incognito.

tomer8007 avatar tomer8007 commented on June 19, 2024

Nice :)
I agree, the UI is the more creative part. We do already have a context-menu detection in the code, so maybe you could add "Show original message" option or so when you open the context menu of a message

from whatsapp-web-incognito.

tomer8007 avatar tomer8007 commented on June 19, 2024

An alternative is to block the edited version entirely (which you seem to actually do), but this is probably not something everybody would want to happen. In this case, adding the UI option is easy

from whatsapp-web-incognito.

tomer8007 avatar tomer8007 commented on June 19, 2024

@neo2701 You are more than welcome to open a PR (even without UI)

from whatsapp-web-incognito.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.