TAMailMessageErrorFix.js

Fix an script error when writing a new message.

  1. // ==UserScript==
  2. // @name TAMailMessageErrorFix.js
  3. // @description Fix an script error when writing a new message.
  4. // @author VisiG
  5. // @version 0.2
  6. // @namespace https://prodgame*.alliances.commandandconquer.com/*/index.aspx*
  7. // @include https://prodgame*.alliances.commandandconquer.com/*/index.aspx*
  8. // ==/UserScript==
  9.  
  10. (function () {
  11. var TAMailMessageErrorFix_main = function () {
  12. function TAMailMessageErrorFix_checkIfLoaded() {
  13. if (PerforceChangelist >= 443425) { // patch 16.1
  14. try {
  15. if (typeof qx !== 'undefined' && typeof qx.core !== 'undefined' && typeof qx.core.Init !== 'undefined') {
  16. try {
  17. for (var key in webfrontend.gui.mail.MailMessage.prototype) {
  18. if (webfrontend.gui.mail.MailMessage.prototype.hasOwnProperty(key) && typeof(webfrontend.gui.mail.MailMessage.prototype[key]) === 'function') { // reduced iterations from 20K to 12K
  19. strFunction = webfrontend.gui.mail.MailMessage.prototype[key].toString();
  20. if (strFunction.indexOf("this.kids") > -1) {
  21. keyBackup = key + "Base";
  22. webfrontend.gui.mail.MailMessage.prototype[keyBackup] = webfrontend.gui.mail.MailMessage.prototype[key];
  23. var matches = strFunction.match(/var (\S*)=this\.(.*)\.getChildren/);
  24. var arrayParent = matches[2];
  25. webfrontend.gui.mail.MailMessage.prototype[key] = eval('(' +
  26. 'function ()' +
  27. '{this.kids = this.'+arrayParent+'.getChildren();' +
  28. 'this.'+keyBackup+'();' +
  29. '}'
  30. + ')') ;
  31. console.log("TAMailMessageErrorFix: fixed");
  32. break;
  33. }
  34. }
  35. }
  36. } catch (e) {
  37. console.error("TAMailMessageErrorFix: " + e);
  38. }
  39. } else {
  40. window.setTimeout(TAMailMessageErrorFix_checkIfLoaded, 1000);
  41. }
  42. } catch (e) {
  43. console.log("TAMailMessageErrorFix_checkIfLoaded: ", e);
  44. }
  45. }
  46. }
  47.  
  48. if (/commandandconquer\.com/i.test(document.domain)) {
  49. window.setTimeout(TAMailMessageErrorFix_checkIfLoaded, 1000);
  50. }
  51. }
  52. try {
  53. var script = document.createElement("script");
  54. script.innerHTML = "(" + TAMailMessageErrorFix_main.toString() + ")();";
  55. script.type = "text/javascript";
  56. document.getElementsByTagName("head")[0].appendChild(script);
  57. } catch (e) {
  58. console.log("TAMailMessageErrorFix: init error: ", e);
  59. }
  60. })();