Skip to content

Adding steam-collections-plus v1.0.0 #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

luthor112
Copy link
Contributor

No description provided.

@shdwmtr
Copy link
Collaborator

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.

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