What is in the rubber covering just before the connector of my laptop adapter?

I've seen it on Samsung and lenovo laptop chargers, not sure about the others. My charger was damaged so I had to rip it apart. Just wondering if it would make any difference if I connect the wire directly with the pin bipassing this component(is it a real component like some capacitor in the first place?)?

Might be the magnetic choke that prevents electronic noise getting into the laptop circuits. Keep it.

When a laptop charger is damaged you REPLACE IT. You can buy a decent aftermarket one for about US$25 or less. You don't need to get the official one.
If there's a piece around the cable it is a toroid for magnetics stability. If at the end of the brick it is to keep the cable in the brick.
The electronics are in the brick and the laptop.
Even an electrical engineer would not try to repair the brick.
If the wire plug is damaged you might do a temporary fix until you get the new one.
The most difficult and expensive is inside the laptop where the DC jack is a high failure rate.
The connector or cable inside is not expensive but labor to get at it difficult.
If a sub-card is used, that is custom.

If the fail is not in the laptop, just replace the DC charger.