What if…

… You could write Messenger patches in JavaScript? I guess it could look something like this:

function CL_onCreatedElement(resid, root) {
	if (resid=="mainContentResID") {
		var TabsAndAds=root.FindDescendent("TabsAndAds");
		if (TabsAndAds)
			TabsAndAds.SetValue("LayoutPos",new Value(-3));
	}
}

function Convo_onCreatedElement(resid, root) {
	if (resid=="convframeresid") {
		var adbannergutter=root.FindDescendent("adbannergutter");
		if (adbannergutter)
			adbannergutter.SetValue("LayoutPos",-3);
	}
}

//Patches contained in this file
Patches=[
	{
		id: "ContactListAdvert",
		name: "Remove Contact-list Advertisement",
		version: "1.0",
		author: "A. Nonymous",
		website: "http://www.google.com/",
		onCreatedElement: CL_onCreatedElement
	},
	{
		id: "ConvoTextAdvert",
		name: "Remove Conversation Text Advertising",
		version: "1.0",
		author: "A. Nonymous",
		website: "http://www.google.com/",
		onCreatedElement: Convo_onCreatedElement
	}
];
//Register patches
for (var i in Patches) {
	RegisterPatch(Patches[i].id,Patches[i]);
}

The above code works just like you’d expect it to, thanks to a new project I’m working on. For now it features only a very very small subset of the DirectUI library, just enough to make the above work (+ some debugging, obviously), but I plan to expand it to create an incredibly flexible platform for writing patches, skins, and later maybe even plugins.

It’s the spiritual successor of the abandoned Project M or Modumes project. Basically Project M was too complex, by using Windows JScript and allowing any other language to write modules in, I faced some problems (mainly threading) that I could not reliable fix.

To create something that could reliable interface with the DirectUI, I needed to have an enviroment where everything, or at least the parts interfacing with DirectUI, would be running from the main thread. My eye first fell on LUA, later on Squirrel, but in the end I figured that although those two scripting languages were incredibly powerful and small, I wanted something a tad more manageable. Eventually I figured the best language would be JavaScript, and Google’s V8 EngineΒ allowed me all I needed:

  • Quick execution (although Mozilla’s TraceMonkey is apparently slightly faster, V8 does a really good job, and was easier to embed)
  • Easy embedding
  • Easy extensible (adding new objects)
  • Easy to learn (Plus! uses a variant of JavaScript too, and all client-side web development is JavaScript too)
  • No threading issues

A weekend plus several hours in the evenings further, and I have a working prototype, yay! πŸ™‚

My current goals:

  • Ability to write quick patches
    • Without having to replace the entire UIB/XML
    • Without having to convert back and forth from UIB
    • Without having to update for each and every minor update
  • Ability to bind to element events (e.g. onMouseOver, onClick)
  • Ability to interface with the Messenger API
  • Ability to set timers from patches
  • Ability to interface with outside programs
  • Ability to share functions between scripts

5 thoughts on “What if…”

  1. > Ability to bind to element events (e.g. onMouseOver, onClick)

    This would allow for such things StuffPlug used to offer, like editing the Display Name right from the contact list… A question I got is, what environment would such patches need to run? And what about the interopability with e.g. Plus!’s scripting engine?

  2. Yes, I’m still subscribed to the scripters list too… πŸ˜›

    This sounds like a very interesting project indeed! So basically, this is like a HTML Document Object Model for Messenger windows, with ID selectors and event handlers? Now that would open up some great possibilities! :O

    Keep us up to date about this! πŸ™‚

  3. this looks great my friend… looking forward to see the ending of this adventure…

    btw I asked somehow your email address to add you in messenger to be able to help you whenever you needed something from me (like test, debug, graphic design, etc…) but it was rejected due to some kind of shyness :P… so if you want help don’t doubt adding me… I will be honored of having you in my CL…

    take care dude… and keep doing well…

Leave a Reply

Your email address will not be published. Required fields are marked *