No more black Broadway Hat, and no more home losing streak.

The Rangers did what they could to “change the karma,” as Brendan Smith put it, and part of that was replacing their old hat given out to their chosen player of the game with a new beige fedora, small bright feather and all.

Mats Zuccarello was its first recipient as he collected three assists in the Rangers’ first win at the Garden since Feb. 19, a 4-3 victory over the Flyers on Sunday night that eliminated Philadelphia from playoff contention.

The victory broke an eight-game home winless streak (0-5-3) for the Rangers (47-26-6), and it allowed them to get one more monkey off their backs as they approach the postseason, all but entirely locked in to the first wild-card spot.

“We had a couple things going on in the room, just tried to change it up,” said Smith, who recorded his first goal as a Ranger 7:10 into the second period to give his team a 2-1 lead. “It was good to get the win and prepare for the playoffs.”

Things got quite dicey at the end, when a 4-1 lead quickly turned into 4-3 with Philadelphia goalie Anthony Stolarz on the bench for the extra attacker and the Flyers getting goals from Brayden Shenn and Valterri Filpulla in a span of 51 seconds. Smith then took his second penalty of the final frame, and the Flyers had a 6-on-4 man-advantage for the final 45 seconds.

Goalie Henrik Lundqvist had to make a sprawling glove save on Claude Giroux with 15 seconds left, but that turned out to be just enough to avoid disaster.

“It was a long reach, but obviously it was important to get the win here,” said Lundqvist, who was solid if not overly tested in making 19 saves in his fourth start since returning from a hip injury. “The way we played, we had it under control and the last two [minutes] there, we need to keep our focus for 60 minutes.”

Playing incomplete games and showing discouraging inconsistency had defined this streak at home, as well as the overall 6-7-4 malaise the Rangers carried over the previous 17 games. It seems their focus had wavered with the postseason looming just around the corner, and as they tried to work on their game, the good came in equal measure with the bad.

“I think we are trying to relay to the younger guys, and obviously as a leadership group we know that we can’t just coast our last three games and expect to ready for the Game 1 on the road,” said defenseman Dan Girardi, as the Rangers are very likely to face the Atlantic Division-leading Canadiens in the first round. “The results matter, but I think our 60-minute game, how we handle ourselves, how we handle the puck defensively, I think we are more worried about that the overall result.”

There certainly were lapses in puck management and defensive structure throughout this game, an example coming when the three Rangers were standing around as Filppula scored his first of two goals just 33 seconds into the second period to make it 1-0. But a power-play goal from Mika Zibanejad just over three minutes later was then followed by Smith’s goal, joining the rush and taking a great feed from Zuccarello before lifting a backhand over Stolarz.

Oscar Lindberg than finished his own rebound to make it 3-1 at 7:01 of the third period, followed two minutes later by Chris Kreider getting his team-leading 28th goal of the season on a deflection of a Derek Stepan centering feed, making it 4-1 with 10:50 left to play.

“That line was dominating,” coach Alain Vigneault said of the Kreider-Stepan-Zuccarello unit which combined for six points. “All three of those guys played extremely well.”

So it got a little nervous at the end, but the result at home was finally different. Now the new hat will travel with the Rangers into the playoffs, where full-game performances are going to be needed or changing the karma won’t matter.

“I’m not going to be the one to leak the superstitions,” Stepan said, “but we were finally able to get it done here.”