theahura / shoot-the-messenger

Script to auto-unsend all messages from a facebook messenger chat
Other
190 stars 27 forks source link

Plugin Don't work #98

Closed jbartak closed 1 year ago

jbartak commented 1 year ago

Describe the bug

main.js:83 Uncaught (in promise) TypeError: Cannot use 'in' operator to search for 'scrollTop' in null
    at getScroller (main.js:83:24)
    at prepareDOMForRemoval (main.js:133:3)
    at unsendAllVisibleMessages (main.js:162:36)
    at runner (main.js:285:29)
    at removeHandler (main.js:393:24)

To Reproduce Steps to reproduce the behavior:

  1. Go to messenger.com and open specific chat
  2. Click on Remove messages
  3. See error

Expected behavior Plugin works.

Screenshots image

Desktop (please complete the following information):

Logs N/A

theahura commented 1 year ago

This happens when the extension can't find a scroll bar in the messenger chain. That in turn can happen for a few reasons

To fix the former, test on a longer messenger chain. I recommend just messaging yourself to see if it works

To fix the latter, we'll need to update the code. As a test, try the following code in the chrome dev console:

MY_ROW_QUERY = '.x78zum5.xdt5ytf.x193iq5w.x1n2onr6.xuk3077:has(> span)'; // Also used for finding the scroller (we just go up to the first parent w/ scrollTop)
PARTNER_CHAT_QUERY = '.x6prxxf.x1fc57z9.x1yc453h.x126k92a.xzsf02u'; // Partner chat text innerText, used for searching
UNSENT_MESSAGE_QUERY = '[aria-label="You unsent a message"]'; // In case a user has none of their own messages on screen and only unsent messages, this serves to pick up the scroll parent.

const query = `${MY_ROW_QUERY}, ${PARTNER_CHAT_QUERY}, ${UNSENT_MESSAGE_QUERY}`;
let el = document.querySelectorAll(query);

console.log(el)

This code just checks to see if the queries for the messenge row works as intended.

If you get a chance to try either result, update the thread with what you find