vtnorton / infinite-craft-multiplayer

This is a Chrome extension that adds a multiplayer feature to the game Infinite Craft (this also works in Edge)
13 stars 2 forks source link

Request for Comment - Infinite Craft project compatibility meta tags #2

Open Spatchy opened 7 months ago

Spatchy commented 7 months ago

Hi, I'm Spatchy, the developer of Infinite Craft++, another Infinite Craft extension.

I have been communicating with developers of several Infinite Craft projects and we have started to agree on a very simple communication scope to make projects (extensions, userscripts, etc.) that modify the game aware of other projects that are installed. The aim is to try and increase compatibility between projects so that end-users don't have to choose between one project or another, and to make things easier for the developers of such projects.

The currently proposed solution is for each project to add a <meta ic-compat> tag to the head of the page, containing information about itself that other projects can read and decide which of its own features it should enable or disable to prevent conflicts. I have drafted a document proposing in more detail how these tags would work. If you have any comments you would like to add, please respond to this issue or issue #29 in the IC++ repo. We would greatly appreciate your input.

vtnorton commented 7 months ago

Hi! Awesome project!

I had updated the read-me with an important note: my extension is not completely functional, just proof of concept, but it's open to PR and Issues and if Neal (the game developer) wants, a partnership!

I've created an insightful blog post about how I created this extension. You can read it here and it contains details of what needs to be done, and how stuff was made.

vtnorton commented 7 months ago

But to be honest, I really wanted to make it work fully. Until them I don't think it would be a good idea to add <meta ic-compat>, because it's not working property.

My biggest issues are to:

  1. capture events of when an item is created and moved or
  2. not just insert a new adjacent HTML before the end for the .instances div.

I used this code (MutationObserver) to make the resolve issue, but it's not perfect

const instances = document.querySelector('.instances div') as Element
const observer = new MutationObserver(function (mutations: MutationRecord[]) {
    // SOME CODE HERE
})
observer.observe(instances, { childList: true })

With your experience @Spatchy, do you have any idea on how to improve these two bits? I believe after this would be more possible to have a fully functional extension on my end.

Spatchy commented 7 months ago

To my knowledge, there's no way of doing this with an extension because it would require patching or hooking into functions already on the page. Due to the way extensions are sandboxed this isn't possible as far as I'm aware. You may want to look into userscripts as an alternative which don't have such restrictions. A good example of a userscript that runs on Infinite craft is Mikarific's Infinite Craft Helper. I'm not experienced with userscripts though so the dev channel in Mikarific's Discord server might be a good place to ask for help.

vtnorton commented 7 months ago

Thanks! I will enter their Discord and take a closer look