Roseanne Barr is blaming Ambien for her racist tweets and telling her fans, "I'm not a racist, just an idiot who made a bad joke."

Sanofi, the maker of Ambien, responded with a statement full of shade: "While all pharmaceutical treatments have side effects, racism is not a known side effect of any Sanofi medication."

Barr's Ambien explanation was part of an hours-long tweetstorm reacting to ABC's cancellation of her hit show "Roseanne."

She had said on Tuesday that she was leaving Twitter, but she just can't seem to log off.

She zig-zagged between apologizing for her foul Twitter behavior and retweeting memes that made her apology sound insincere. She retweeted fans who portrayed her as the victim of a liberal media double standard. All told, she posted more than 100 times.

Later in the day, President Trump joined her on Twitter. His first public reaction to the show's cancellation was a tweet criticizing Disney CEO Bob Iger.

Related: Trump breaks silence on Roseanne Barr scandal

Trump and Barr have been prominent supporters of each other. They both delight in attacking Democrats.

In this case, Barr was fired for her Tuesday tweet about former Obama aide Valerie Jarrett. But she kept it up on Wednesday, retweeting photos of Jarrett side by side with an ape.

It was Barr's earlier tweet about Jarrett that caused outrage and ultimately led to the show's cancellation. In a response to a comment about Jarrett, Barr had said: "Muslim brotherhood & planet of the apes had a baby=vj."

Barr still claims she was just joking when she compared Jarrett to "Planet of the Apes" and the Muslim Brotherhood in a tweet on Tuesday morning.

In a reply to one of her fans, she said "I honestly thought she was Jewish and Persian-ignorant of me for sure, but...i did."

She also said she had been on Ambien, a medication used to treat insomnia, at the time.

She tweeted, "guys I did something unforgiveable so do not defend me. It was 2 in the morning and I was ambien tweeting -- it was memorial day too -- i went 2 far & do not want it defended -- it was egregious Indefensible. I made a mistake I wish I hadn't but...don't defend it please."

She cited Ambien again in a later tweet, saying, "Not giving excuses for what I did(tweeted) but I've done weird stuff while on ambien -- cracked eggs on the wall at 2am etc."

Oddly, she later deleted all of her references to the medication. Nevertheless, Ambien became the #1 trending topic on Twitter on Wednesday morning, leading to Sanofi's public rebuke. Barr's explanation was deemed laughable.

"I have only taken Ambien once ... but I don't remember one of the side-effects being racism," CNN's John Berman tweeted.

Related: The inside story of how ABC fired Roseanne Barr

In one of her other deleted tweets, Barr said "I'm sorry 4 my tweet, AND I will also defend myself as well as talk to my followers. so, go away if u don't like it. I will handle my sadness the way I want to. I'm tired of being attacked & belittled more than other comedians who have said worse."

Some of her replies to fans clearly expressed how she feels. At one point she said she believes she was fired because of fears over a potential boycott of the show's advertisers. She also lashed out at co-stars Michael Fishman and Sara Gilbert.

"You throw me under the bus. nice!" she said in a tweet directed at Fishman.

Her Twitter account had a manic feel throughout the morning. Through her selection of retweets, Barr implied that she was fired over her support for President Trump. One of the posts she shared said, inexplicably, "they brought the show back so they could inevitably cancel the show when she said something they didn't like."

But then she deleted her retweet of that post.

Another retweet, still up as of 7 a.m. ET, quoted Herman Cain on Fox saying "I believe they were looking for a reason to cancel #Roseanne and here's why. Even though the show was a ratings success, forces within ABC didn't like the fact that her conservative defense of certain things was so popular."

i honestly thought she was Jewish and Persian-ignorant of me for sure, but...i did. — Roseanne Barr (@therealroseanne) May 30, 2018

Barr also continued to tweet about George Soros, a liberal donor who has been painted as the villain in many right-wing conspiracy theories.

One message she re-tweeted on Wednesday falsely accused the Hungary-born Jewish billionaire of collaborating with the Nazis.

Barr also said her firing "worked out" because she "would leave when they started to try to censor me."

i think i know what really happened. It has made me mad, but as I told u-i would leave when they started to try to censor me, so it all worked out — Roseanne Barr (@therealroseanne) May 30, 2018

After a head-spinning 24 hours, there are several outstanding questions:

-- What will ABC schedule Tuesdays at 8 p.m. this fall in place of "Roseanne?"

-- Is there any possibility of a "Roseanne" sitcom without Barr? A way to keep the cast and crew together in some way?

-- Will there be any measurable backlash from her fans?

-- Will President Trump comment at all?

-- What will Barr do next?

Tom Werner, her longtime producing partner, told Deadline.com that he supported ABC's decision.

He said he hoped "Roseanne seeks the help she so clearly needs."