Greasy Fork

Greasy Fork is available in English.

网页版微信助手

Web Wechat helper

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         网页版微信助手
// @namespace    https://muxueqz.top
// @version      0.2
// @description  Web Wechat helper
// @author       muxueqz
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
// @match        *://wx.qq.com/*
// @grant        GM_addStyle
// @grant        GM_notification

// ==/UserScript==
/* jshint ignore:start */
// Generated by CoffeeScript 1.12.8
(function() {
  var bind_mention_user, click_user, close_userselect, contact_list, editarea, get_input_user, get_users, html, origOpen, poll, send_msg, webwxgetcontact_url, webwxinit_url, webwxsync_url;

  origOpen = XMLHttpRequest.prototype.open;

  webwxsync_url = 'https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxsync?';

  webwxinit_url = 'https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxinit?';

  webwxgetcontact_url = 'https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxgetcontact?';

  contact_list = {};

  XMLHttpRequest.prototype.open = function() {
    this.addEventListener('readystatechange', function() {
      var i, j, k, len, len1, modified_response, original_response, ref, ref1, ref2, results, results1, wx_msg;
      bind_mention_user();
      if (this.responseURL.lastIndexOf(webwxgetcontact_url) === 0) {
        original_response = this.responseText;
        modified_response = JSON.parse(original_response);
        console.log('webwxgetcontact_url request');
        ref = modified_response.MemberList;
        results = [];
        for (j = 0, len = ref.length; j < len; j++) {
          i = ref[j];
          results.push(contact_list[i.UserName] = i.NickName);
        }
        return results;
      } else if (this.responseURL.lastIndexOf(webwxinit_url) === 0) {
        original_response = this.responseText;
        modified_response = JSON.parse(original_response);
        console.log('webwxinit_url request');
        return console.log(modified_response);
      } else if (this.responseURL.lastIndexOf(webwxsync_url) === 0 && this.readyState === 4) {
        original_response = this.responseText;
        modified_response = JSON.parse(original_response);
        if (modified_response.AddMsgList.length > 0) {
          ref1 = modified_response.AddMsgList;
          results1 = [];
          for (k = 0, len1 = ref1.length; k < len1; k++) {
            wx_msg = ref1[k];
            console.log(wx_msg);
            console.log(contact_list[wx_msg.FromUserName], wx_msg.FromUserName);
            if (wx_msg.MsgType === 10002) {
              Object.defineProperty(this, "response", {
                writable: true
              });
              wx_msg.Content = 'test防撤回';
              GM_notification("有人想撤回消息噢");
              modified_response = JSON.stringify(modified_response);
              results1.push(this.response = modified_response);
            } else if (((ref2 = wx_msg.MsgType) === 10000 || ref2 === 10001) && (wx_msg.Content.indexOf("发出红包")) > -1) {
              results1.push(console.log("据说发出了红包"));
            } else if (wx_msg.MsgType === 10000) {
              results1.push(GM_notification("据说收到红包"));
            } else {
              results1.push(void 0);
            }
          }
          return results1;
        }
      }
    });
    return origOpen.apply(this, arguments);
  };

  get_users = function(source_text) {
    var select;
    select = document.getElementById("userSelectionBox");
    return select.onclick = function() {
      var text, val;
      text = select.value;
      if (text.length > 1) {
        val = text;
        return console.log(val);
      }
    };
  };

  click_user = function() {
    return console.log('click');
  };

  close_userselect = function() {
    return $('#userSelectionBox').css('display', 'none');
  };

  console.log('console log');

  GM_notification("wx_helper enable");

  GM_addStyle('.main_inner{max-width:70%}');

  GM_addStyle('.main{height:88%; padding-top:50px}');

  GM_addStyle('.bubble{font-size:16px}');

  GM_addStyle('.chat .box_ft .content .flex{font-size:16px}');

  send_msg = angular.element(document.querySelector(".btn.btn_send")).scope();

  editarea = document.getElementById("editArea");

  html = "<ul class=\"dropdown_menu\" id=\"userSelectionBox\" style=\"\n    position: absolute;\n    display: none;\n    width: auto;\n    left: 0;\n    right: auto;\n    top: 50%;\n    max-height: 25%;\n    /* z-index: 900; */\n    right: auto;\n    float: left;\n    min-height: auto;\n    min-width: auto;\n    background: transparent;\n\">\n</ul>";

  $("#chatArea").append(html);

  document.getElementById('userSelectionBox').onclick = function(a) {
    var text;
    text = a.target.name;
    console.log(text);
    return click_user();
  };

  get_input_user = function() {
    var clean_index, editarea_ng, editarea_scope, html_item, input, input_user, input_user_lower, item, j, len, member, member_list, newMessage, new_msg, ref, scope, source_text;
    source_text = editarea.innerHTML;
    input = editarea.innerHTML.replace('<br>', '').replace('</br>', '').split(' ').slice(-1)[0];
    if ('@' === input[0] && input.length > 1) {
      console.log('@input:' + input);
      html = "<select id=\"userSelectionBox\">\n    <option value='" + item + "'>" + item + "</option>\n</select>";
      newMessage = html;
      scope = angular.element('#chatArea').scope();
      member_list = [];
      input_user = input.slice(1, -1);
      input_user_lower = input.slice(1, -1).toLowerCase();
      $('#userSelectionBox').empty();
      ref = scope.currentContact.MemberList;
      for (j = 0, len = ref.length; j < len; j++) {
        member = ref[j];
        item = member.NickName;
        if (item.toLowerCase().lastIndexOf(input_user_lower) !== -1 && input_user_lower.length > 0) {
          html_item = "<li>\n    <a href=\"javascript:;\" title=\"" + item + "\" name=\"" + item + "\">\n        " + item + " </a>\n</li>";
          $('#userSelectionBox').append(html_item);
          console.log(html_item);
          member_list.push(item);
        }
      }
      console.log(member_list);
      clean_index = input.lastIndexOf(input_user) - (2 + input_user.length + 1);
      console.log('clean_index:' + clean_index);
      console.log('input_user:' + input_user);
      console.log('source:' + source_text.slice(0, +clean_index + 1 || 9e9));
      console.log('member_list length:' + member_list.length);
      if (member_list.length > 0) {
        new_msg = source_text.slice(0, +clean_index + 1 || 9e9) + member_list.pop() + ' ';
        editarea_ng = angular.element('#editArea');
        editarea_ng.focus();
        editarea_ng.html('');
        editarea_scope = editarea_ng.scope();
        editarea_scope.insertToEditArea(new_msg);
        console.log('new_msg:' + new_msg);
        $('#userSelectionBox').css('display', 'block');
        return setTimeout(close_userselect, 3000);
      }
    }
  };

  editarea.onkeypress = function(key) {
    console.log('keypress:' + key.key);
    if (key.key === '@') {
      return setTimeout(get_input_user, 10);
    }
  };

  bind_mention_user = function() {
    editarea = document.getElementById("editArea");
    return editarea.onkeypress = function(key) {
      console.log('keypress:' + key.key);
      if (key.key === '@') {
        return setTimeout(get_input_user, 10);
      }
    };
  };

  (poll = function() {
    bind_mention_user();
    return setTimeout(poll, 1000);
  })();

}).call(this);