amanharwara / altus

Desktop client for WhatsApp Web with themes, notifications and multiple account support
GNU General Public License v3.0
488 stars 68 forks source link

Prevent WhatsApp from scrolling all the way to the top when you reply to a message from the bottom #144

Open iamvinny opened 3 years ago

iamvinny commented 3 years ago

It would be super useful if Altus had an option to prevent WhatsApp from automatically scrolling all the way to the top when you reply to a message from the bottom. This way, when you reply to an older message from the bottom, you won't have to scroll all the way back to the bottom to reply to the next chat.

It can be very useful for companies who are using WhatsApp Business to stay in touch with customers, or individuals who get a lot of messages.

It may seem simple, but I'm not quite sure how hard it would be to implement something like this on Altus.

This piece of code used to work just fine, but ever since WhatsApp updated their web client (about 2 months ago) it stopped working.

if(document.URL.includes('web.whatsapp.com') == true){

console.log('script added')

var p=setInterval(function(){

  if(document.querySelectorAll('.DuUXI')[0]){

    var t=setInterval(function(){

      document.querySelectorAll('.DuUXI')[0].addEventListener('keydown',function(){
      if (event.keyCode === 13) {

        var y = document.querySelector('#pane-side').scrollTop

        setTimeout(function() {

             document.querySelector('#pane-side').scrollTop = y
                    }, 1500);
      }

    })
    },1000);

    clearInterval(p)

  }
},500)

}