Uncaught SyntaxError: await is only valid in async functions, async generators and modules
(Firefox)
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
Same error as well but am running via Node.js
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.
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 likenavigator.userAgentbut for those who just want to run the script you can replace the line that starts withvar 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.
For me it worked using an IIFE, see here.
(async function main () {
// Paste the entire code here
})();
I tried the user agent thing and it still broke, but wrapping it as described in LoLei's post seems to have done it
Ok let me tell you with node it just didn't work. If you want it to work
- wrap it in async like both azrogers Pull request and LoLei said
- 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)
- 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