Roger Stone, a longtime confidant of President Donald Trump, accompanied by his wife Nydia Stone, left, arrived at federal court in Washington, on Tuesday. (Sait Serkan Gurbuz/AP)

A federal judge on Tuesday barred Roger Stone from all communications through Instagram, Twitter and Facebook until after his trial, rebuking the longtime Republican operative for resorting to “middle-school” behavior online that could prejudice future jurors.

The judge ordered Stone not to post anything on the three popular sites, extending a previous gag order that prohibited him from discussing his case or participants in it with the media, on other social media or in public settings.

For the close confidant of President Trump, social media platforms have been a mainstay as he contests — and disparages — his prosecution on charges of lying to Congress and witness tampering brought by special counsel Robert S. Mueller III.

On Tuesday, U.S. District Judge Amy Berman Jackson’s displeasure with Stone was evident as she read aloud from months of Stone’s online postings and reprimanded the defendant as he sat in court.

“What am I supposed to do with you? . . . Once again I am wrestling with behavior that has more to do with middle school than a court of law,” Jackson said, adding that whether the problem is “you can’t follow orders, or won’t, I need to help you out.”

Stone has pleaded not guilty to charges of lying about his efforts to gather information about Democratic Party emails hacked and leaked by Russian operatives in 2016. He has a trial scheduled for November.

Jackson in February ordered Stone to cease making public statements attacking his indictment, the conduct of the FBI, intelligence agencies and government officials in the investigation into Russian interference in the 2016 U.S. election, after Stone ignored earlier warnings and posted a photograph of the judge’s face next to what appeared to be gunsight crosshairs.

Jackson did not say how she would enforce the expanded order but held out the possibility of a contempt hearing after trial. Holding such a hearing now would waste the resources of the court and the legal teams, and it could generate more pretrial publicity that the order is meant to tamp down, she said.

Stone was in court Tuesday for a previously scheduled hearing on a request from his lawyers to suppress evidence they said was gathered through a flawed search warrant underpinned by what the defense says was secondhand unreliable information.

Prosecutors led by Assistant U.S. Attorney Jonathan Kravis said Stone’s efforts appeared aimed at creating an ongoing “sideshow” and to “backdoor a defense conspiracy theory” into the case, namely that government findings of Russian interference in the campaign were based on a “false narrative.”

Jackson took the motion under advisement and said she would rule later.

The judge then turned to Stone’s compliance with her gag order, saying it had been “as clear as day,” before reading from some of Stone’s vitriolic and profane social media attacks.

She said postings in Stone’s Instagram account included photos of commentators referring to the “Russia Hoax” and claiming Stone’s defense has exposed “the ‘intelligence community’s’ betrayal of their responsibilities” and revealed “deeply disturbing lessons about the level of corruption at the top levels of the agencies charged with protecting us from external threats.”

Jackson also cited a March 29 posting by Stone using scatological terms to mock House Intelligence Committee Chairman Adam B. Schiff (D-Calif), whose committee also investigated the Russian election effort, and a June 2 message in which Stone called John O. Brennan, CIA director at the time of the election, a “psycho” who “must be charged, tried, convicted — and hung for treason.”

With Stone sitting at a defense table in a light blue suit with arms tightly folded, Jackson also cited a Feb. 27 text by Stone to a BuzzFeed reporter denying the truthfulness of House testimony by a witness in the investigation, Trump’s former personal lawyer Michael Cohen.

In Stone’s defense, attorney Bruce Rogow called the gag order, which he had helped draft, “overbroad,” and said Stone should not be prevented from commenting about the media, court filings or U.S. officials in general.

Above all, Rogow said, Stone’s social media following was minimal. According to his Instagram account, Stone has about 50,000 followers, but only one hundred to two hundred “liked” some of the posts in dispute. Stone was banned by Twitter in October 2017 for expletive-laden tweets about CNN.

“None of these things are the kind of thing that have any reasonable basis for affecting a fair trial,” Rogow said.

“I am sorry the court is offended by these things and thinks they violate the court’s order. I understand how one can look at them and come to the conclusion and find they’re at the line or across the line,” Rogow acknowledged. “But Mr. Stone has tried to hew to that line.

Jackson responded sternly, “There’s some added verbiage there. I don’t think recognizing or determining a line has been crossed has to do with whether a person is offended.”

She said Rogow “twisted himself into a pretzel” trying to defend Stone.