{"id":37,"date":"2009-01-14T17:13:32","date_gmt":"2009-01-14T22:13:32","guid":{"rendered":"http:\/\/fw.hardijzer.nl\/?p=37"},"modified":"2009-01-14T17:22:51","modified_gmt":"2009-01-14T22:22:51","slug":"what-if","status":"publish","type":"post","link":"https:\/\/fw.hardijzer.nl\/?p=37","title":{"rendered":"What if&#8230;"},"content":{"rendered":"<p>&#8230; You could write Messenger patches in JavaScript? I guess it could look something like this:<\/p>\n<pre><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nfunction CL_onCreatedElement(resid, root) {\r\n\tif (resid==&quot;mainContentResID&quot;) {\r\n\t\tvar TabsAndAds=root.FindDescendent(&quot;TabsAndAds&quot;);\r\n\t\tif (TabsAndAds)\r\n\t\t\tTabsAndAds.SetValue(&quot;LayoutPos&quot;,new Value(-3));\r\n\t}\r\n}\r\n\r\nfunction Convo_onCreatedElement(resid, root) {\r\n\tif (resid==&quot;convframeresid&quot;) {\r\n\t\tvar adbannergutter=root.FindDescendent(&quot;adbannergutter&quot;);\r\n\t\tif (adbannergutter)\r\n\t\t\tadbannergutter.SetValue(&quot;LayoutPos&quot;,-3);\r\n\t}\r\n}\r\n\r\n\/\/Patches contained in this file\r\nPatches=&#x5B;\r\n\t{\r\n\t\tid: &quot;ContactListAdvert&quot;,\r\n\t\tname: &quot;Remove Contact-list Advertisement&quot;,\r\n\t\tversion: &quot;1.0&quot;,\r\n\t\tauthor: &quot;A. Nonymous&quot;,\r\n\t\twebsite: &quot;http:\/\/www.google.com\/&quot;,\r\n\t\tonCreatedElement: CL_onCreatedElement\r\n\t},\r\n\t{\r\n\t\tid: &quot;ConvoTextAdvert&quot;,\r\n\t\tname: &quot;Remove Conversation Text Advertising&quot;,\r\n\t\tversion: &quot;1.0&quot;,\r\n\t\tauthor: &quot;A. Nonymous&quot;,\r\n\t\twebsite: &quot;http:\/\/www.google.com\/&quot;,\r\n\t\tonCreatedElement: Convo_onCreatedElement\r\n\t}\r\n];\r\n\/\/Register patches\r\nfor (var i in Patches) {\r\n\tRegisterPatch(Patches&#x5B;i].id,Patches&#x5B;i]);\r\n}\r\n<\/pre>\n<p>The above code works just like you&#8217;d expect it to, thanks to a new project I&#8217;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.<\/p>\n<p>It&#8217;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.<\/p>\n<p>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 <a href=\"http:\/\/www.lua.org\/\">LUA<\/a>, later on <a href=\"http:\/\/www.squirrel-lang.org\/\">Squirrel<\/a>, 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 <a href=\"http:\/\/code.google.com\/p\/v8\/\">Google&#8217;s V8 Engine<\/a>\u00a0allowed me all I needed:<\/p>\n<ul>\n<li>Quick execution (although Mozilla&#8217;s TraceMonkey is apparently slightly faster, V8 does a really good job, and was easier to embed)<\/li>\n<li>Easy embedding<\/li>\n<li>Easy extensible (adding new objects)<\/li>\n<li>Easy to learn (Plus! uses a variant of JavaScript too, and all client-side web development is JavaScript too)<\/li>\n<li>No threading issues<\/li>\n<\/ul>\n<p>A weekend plus several hours in the evenings further, and I have a working prototype, yay! \ud83d\ude42<\/p>\n<p>My current goals:<\/p>\n<ul>\n<li>Ability to write quick patches\n<ul>\n<li>Without having to replace the entire UIB\/XML<\/li>\n<li>Without having to convert back and forth from UIB<\/li>\n<li>Without having to update for each and every minor update<\/li>\n<\/ul>\n<\/li>\n<li>Ability to bind to element events (e.g. onMouseOver, onClick)<\/li>\n<li>Ability to interface with the Messenger API<\/li>\n<li>Ability to set timers from patches<\/li>\n<li>Ability to interface with outside programs<\/li>\n<li>Ability to share functions between scripts<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>&#8230; You could write Messenger patches in JavaScript? I guess it could look something like this: function CL_onCreatedElement(resid, root) { if (resid==&quot;mainContentResID&quot;) { var TabsAndAds=root.FindDescendent(&quot;TabsAndAds&quot;); if (TabsAndAds) TabsAndAds.SetValue(&quot;LayoutPos&quot;,new Value(-3)); } } function Convo_onCreatedElement(resid, root) { if (resid==&quot;convframeresid&quot;) { var adbannergutter=root.FindDescendent(&quot;adbannergutter&quot;); if (adbannergutter) adbannergutter.SetValue(&quot;LayoutPos&quot;,-3); } } \/\/Patches contained in this file Patches=&#x5B; { id: &quot;ContactListAdvert&quot;, name: &hellip; <a href=\"https:\/\/fw.hardijzer.nl\/?p=37\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">What if&#8230;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[32,74,72,29,31],"class_list":["post-37","post","type-post","status-publish","format-standard","hentry","category-messenger","tag-google","tag-javascript","tag-messenger","tag-patch","tag-v8"],"_links":{"self":[{"href":"https:\/\/fw.hardijzer.nl\/index.php?rest_route=\/wp\/v2\/posts\/37","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fw.hardijzer.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fw.hardijzer.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fw.hardijzer.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fw.hardijzer.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=37"}],"version-history":[{"count":12,"href":"https:\/\/fw.hardijzer.nl\/index.php?rest_route=\/wp\/v2\/posts\/37\/revisions"}],"predecessor-version":[{"id":47,"href":"https:\/\/fw.hardijzer.nl\/index.php?rest_route=\/wp\/v2\/posts\/37\/revisions\/47"}],"wp:attachment":[{"href":"https:\/\/fw.hardijzer.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=37"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fw.hardijzer.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=37"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fw.hardijzer.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=37"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}