Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught SyntaxError: await is only valid in async functions, async generators and modules #30

Open
nmlen opened this issue Jan 30, 2024 · 7 comments · May be fixed by #34
Open

Uncaught SyntaxError: await is only valid in async functions, async generators and modules #30

nmlen opened this issue Jan 30, 2024 · 7 comments · May be fixed by #34

Comments

@nmlen
Copy link

nmlen commented Jan 30, 2024

(Firefox)

image

@onexbash
Copy link

onexbash commented Feb 3, 2024

Have the same problem. Also on Firefox

Uncaught SyntaxError: await is only valid in async functions, async generators and modules

But additionally there are hundreds of warnings saying fetch failed:

Source map error: NetworkError when attempting to fetch resource. Resource URL: https://abs.twimg.com/responsive-web/client-web/shared~loader.DMDrawer~bundle.ReaderMode~bundle.DirectMessages~bundle.DMRichTextCompose~bundle.TweetMediaDeta.26b9201a.js Source Map URL: https://ton.local.twitter.com/responsive-web-internal/sourcemaps/client-web/shared~loader.DMDrawer~bundle.ReaderMode~bundle.DirectMessages~bundle.DMRichTextCompose~bundle.TweetMediaDeta.26b9201a.js.map

OS: MacOS
CPU: ARM64 / aarch64
Browser: Firefox-Developer-Edition

@razrunelord
Copy link

Same error as well but am running via Node.js

@schdie
Copy link

schdie commented Mar 17, 2024

In order for this to work on firefox besides wrapping it on an async function like @azrogers points out is necessary to replace navigator.userAgentData (which it's not supported) with something like navigator.userAgent but for those who just want to run the script you can replace the line that starts with var ua = with:
var ua = "Mozilla/5.0 (X11; Linux x86_64; rv:121.1) Gecko/20100101 Firefox/121.1"; or whatever user-agent your browser has.

@schdie
Copy link

schdie commented Mar 18, 2024

In order for this to work on firefox besides wrapping it on an async function like @azrogers points out is necessary to replace navigator.userAgentData (which it's not supported) with something like navigator.userAgent but for those who just want to run the script you can replace the line that starts with var ua = with: var ua = "Mozilla/5.0 (X11; Linux x86_64; rv:121.1) Gecko/20100101 Firefox/121.1"; or whatever user-agent your browser has.

Unfortunately this doesn't fix it in FireFox 123.0.1 x64 Windows 10

Are you sure the problem is the user-agent string? Try changing the same line to: var ua = navigator.userAgent; it should work.

@LoLei
Copy link

LoLei commented May 1, 2024

For me it worked using an IIFE, see here.

(async function main () {
    // Paste the entire code here
})();

@hikingmetalpunk
Copy link

I tried the user agent thing and it still broke, but wrapping it as described in LoLei's post seems to have done it

@federicorosso1993
Copy link

federicorosso1993 commented Oct 20, 2024

Ok let me tell you with node it just didn't work.
If you want it to work

  1. wrap it in async like both azrogers Pull request and LoLei said
  2. not sure if necessary but you can find your useragent and just paste it in the variable like schdie said (it should be the user agent of the browser you used to connect to your twitter account)
  3. open the developer console on your browser and drag/drop the main.js file there (you will see all the code). I've never done it in years since I usually don't use js standalone applications so I was really confused when it didn't work on node but it make sense since it need the cookies too to work and I think this was not made to read a cookie file.

I'm deleting all my tweets right now (I had to request an archive like 2 days ago, I hope I did it right since tweets.js files was the only one requested from the archive... I will update this answer when it finish.
Still a great free tool so I cannot really complain, redact only work if you got under 2-3000 tweets for free... Anything else just ask for money. I just want to quit twitter because after musk got it, he turned it into garbage and I have to delete my tweets now because they want to use data for their AI. I don't need a really complex tool like redact, just a one time use... that's why I like that there is this tool that does the same things... it is just not updated to work but like you can see there is ways to solve it.

PS. For some reason it did not delete everything but I got it under 2000 so I can now use redact for free to delete the missing tweets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants