DeleteAllMessages

Disable all messages button.

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name            DeleteAllMessages
// @version         14.10.31
// @description     Disable all messages button.
// @namespace       https://prodgame*.alliances.commandandconquer.com/*/index.aspx*
// @include         https://prodgame*.alliances.commandandconquer.com/*/index.aspx*
// @author          Nogrod
// ==/UserScript==
(function () {
  var DeleteAllMessages_mainFunction = function () {
    function createTweak() {
      qx.Mixin.define("webfrontend.gui.mail.MMailTab", {
        construct : function () {
          var children = this.getChildren();
          var getObjId = function (children, objid) {
            for (var j = 0; j < children.length; j++) {
              if (children[j].objid == objid)
                return children[j];
            }
            return null;
          };
          for (var i = 0; i < children.length; i++) {
            if (children[i]instanceof qx.ui.container.Composite && getObjId(children[i].getChildren(), "btndelete") !== null) {
              var btnDeleteAllMessages = new qx.ui.form.Button(this.tr("tnf:delete mails"));
              btnDeleteAllMessages.addListener("execute", function () {
                btnDeleteAllMessages.setEnabled(false);
                ClientLib.Net.CommunicationManager.GetInstance().SendSimpleCommand("IGMGetFolders", {}, phe.cnc.Util.createEventDelegate(ClientLib.Net.CommandResult, this, function (context, folders) {
                    console.log(folders);
                    if (folders !== null && folders.length >= 2 && folders[0].i > 0 && folders[1].i > 0) {
                      var folderId = folders[this.getMailboxType() == ClientLib.Data.Mail.EMailBox.Inbox ? 0 : 1].i;
                      ClientLib.Net.CommunicationManager.GetInstance().SendSimpleCommand("IGMGetMsgCount", {
                        folderId : folderId
                      }, phe.cnc.Util.createEventDelegate(ClientLib.Net.CommandResult, this, function (folderId, count) {
                          console.log(count);
                          if (count > 0) {
                            ClientLib.Net.CommunicationManager.GetInstance().SendSimpleCommand("IGMGetMsgHeader", {
                              folder : folderId,
                              skip : 0,
                              take : count,
                              sortColumn : ClientLib.Data.Mail.EMailSort.Time,
                              ascending : false
                            }, phe.cnc.Util.createEventDelegate(ClientLib.Net.CommandResult, this, function (context, mails) {
                                console.log(mails);
                                var mailIds = [];
                                for (var i = 0; ((mails !== null) && (i < mails.length)); i++) {
                                  mailIds.push(mails[i].i);
                                }
                                if (mailIds.length > 0) {
                                  ClientLib.Data.MainData.GetInstance().get_Mail().DeleteMessages(mailIds, (this.getMailboxType() == ClientLib.Data.Mail.EMailBox.Inbox));
                                }
                                btnDeleteAllMessages.setEnabled(true);
                              }), null);
                          } else {
                            btnDeleteAllMessages.setEnabled(true);
                          }
                        }), folderId);
                    } else {
                      btnDeleteAllMessages.setEnabled(true);
                    }
                  }), null);
              }, this);
              children[i].addAfter(btnDeleteAllMessages, getObjId(children[i].getChildren(), "btndelete"));
              break;
            }
          }
        }
      });
      qx.Class.include(webfrontend.gui.mail.MailTab, webfrontend.gui.mail.MMailTab);
    }
    function DeleteAllMessages_checkIfLoaded() {
      try {
        if (typeof loader !== "undefined" && loader.complete && typeof loader.downloadScript === "undefined") {
          createTweak();
        } else {
          setTimeout(DeleteAllMessages_checkIfLoaded, 500);
        }
      } catch (e) {
        if (typeof console !== "undefined") {
          console.log(e + ": " + e.stack);
        } else if (window.opera) {
          opera.postError(e);
        } else {
          GM_log(e);
        }
      }
    }
    setTimeout(DeleteAllMessages_checkIfLoaded, 500);
  };
  var DeleteAllMessagesScript = document.createElement("script");
  var txt = DeleteAllMessages_mainFunction.toString();
  DeleteAllMessagesScript.innerHTML = "(" + txt + ")();";
  DeleteAllMessagesScript.type = "text/javascript";
  document.getElementsByTagName("head")[0].appendChild(DeleteAllMessagesScript);
})();