theahura / shoot-the-messenger

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

Cannot use 'in' operator to search for 'scrollTop' in null #78

Closed maciex closed 2 years ago

maciex commented 2 years ago

Describe the bug Extension did work few times during the tests. But after few tries it stopped working. Errors being logged in dev console.

To Reproduce Steps to reproduce the behavior:

  1. Open one of the Messenger chats
  2. Run the removal using "Remove messages"
  3. Confirm deletion in the query window
  4. Nothing happens
  5. See error in console

Expected behavior Messages deleted in the chat.

Screenshots

Desktop (please complete the following information):

Logs

Got action:  REMOVE
5The resource <URL> was preloaded using link preload but not used within a few seconds from the window's load event. Please make sure it has an appropriate `as` value and it is preloaded intentionally.
main.js:257 Starting runner removal for N iterations:  10
main.js:259 Running count: 
Uncaught (in promise) TypeError: Cannot use 'in' operator to search for 'scrollTop' in null
    at getScroller (main.js:71:24)
    at prepareDOMForRemoval (main.js:119:3)
    at unsendAllVisibleMessages (main.js:148:36)
    at runner (main.js:260:29)
    at removeHandler (main.js:362:24)
maciex commented 2 years ago

It seems that el is null in that are. I did a quick debug and it seems the document.querySelector() method returns null:

ROW_QUERY = '[data-testid="message-container"]';
> '[data-testid="message-container"]'
let el = document.querySelector(ROW_QUERY);
> undefined

I also checked on other chats, but got the same null result

theahura commented 2 years ago

Thanks for the clear replication of the bug. I'm running into issues on my end as well so I can replicate. I'll try and fix this soon but as usual super busy. Might be able to do this next weekend

maciex commented 2 years ago

@theahura let me know if there's any code or even a snippet I could check (I can rerun it in dev mode).

theahura commented 2 years ago

I'm almost positive this is a simple bugfix. There's a list of queries at the top of main.js, one of those queries is no longer valid (probably the one for ROW), and I just need to replace it with a query that does work https://github.com/theahura/shoot-the-messenger/blob/main/main.js#L8

8SecSleeper commented 2 years ago

I changed l8 and l9 with the following, It works, not sure if it works for others? Works as it always had with this code though.

ROW_QUERY = '.x63ui4o.x18i3tt1.x6ikm8r.x10wlt62'; MY_ROW_QUERY = '.x6prxxf.x1fc57z9.x1yc453h.x126k92a.x14ctfv';

maciex commented 2 years ago

This worked for me. I mean most of the messages were unsent. The script ended with error in console (keep in mind that I added the new queries as new lines, so the line numbers are shifted +2):

main.js:206 Removed all holders.
main.js:242 No scroller or load buttons, but we didnt hit the top. Failing.
main.js:384 Failed to complete removal.

Also one of the messages in the chat was not deleted (this is the first message in the conversation).

maciex commented 2 years ago

It seems the script has problems with detecting that new messages should be loaded or we're not on the top message.

I tricked the script to go through all the messages but not delete them. And it fails with the same message (this time the lines should match the source code in master):

main.js:204 Removed all holders.
main.js:240 No scroller or load buttons, but we didnt hit the top. Failing.
main.js:382 Failed to complete removal.
theahura commented 2 years ago

I think this means the MESSAGE_CONTAINER_QUERY is also busted

8SecSleeper commented 2 years ago

It seems the script has problems with detecting that new messages should be loaded or we're not on the top message.

I tricked the script to go through all the messages but not delete them. And it fails with the same message (this time the lines should match the source code in master):

main.js:204 Removed all holders.
main.js:240 No scroller or load buttons, but we didnt hit the top. Failing.
main.js:382 Failed to complete removal.

I opened a pull request with a version that should fix all current issues.

theahura commented 2 years ago

Merged. Thanks a ton @10SecSleeper !