Skip to content

Conversation

luthor112
Copy link
Contributor

No description provided.

@shdwmtr
Copy link
Member

shdwmtr commented May 10, 2025

Just so you know, you should always make an effort to use React instead of manually creating elements. Millennium's API gives you ways to hook Steams internal components to render inside of them instead of finding it by class, and replacing it manually.

For example, this is how millennium patches the Steam context menu.

function RenderSettingsModal(_: any, retObj: any) {
	const index = retObj.props.menuItems.findIndex((prop: any) => prop.name === '#Menu_Settings');

	const [isMillenniumOpen, setIsMillenniumOpen] = useState(false);

	if (index !== -1) {
		retObj.props.menuItems.splice(index + 1, 0, {
			name: 'Millennium Settings',
			onClick: () => {
				setIsMillenniumOpen(true);
			},
			visible: true,
		});
	}

	return (
		<>
			{isMillenniumOpen && <RenderMillennium setIsMillenniumOpen={setIsMillenniumOpen} />}
			{retObj.type(retObj.props)}
		</>
	);
}

const PatchRootMenu = () => {
	const steamRootMenu = findInReactTree(getReactRoot(document.getElementById('root') as any), (m) => {
		return m?.pendingProps?.title === 'Steam' && m?.pendingProps?.menuContent;
	});

	afterPatch(steamRootMenu.pendingProps.menuContent, 'type', RenderSettingsModal.bind(this));
};

This solution wont work for every component though, you'll have to manually sort through the components and reverse them.
You can follow up on discord and I can help you if you need it.

@luthor112
Copy link
Contributor Author

Moved to render(), pls review.

@shdwmtr shdwmtr merged commit 8c242a4 into SteamClientHomebrew:main May 27, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants