0

デフォルト以外の絵文字をサポートするように、ReChat というアドオンを変更しようとしています。

単語全体を置き換えるには、この正規表現を作成する必要があります。メタ文字を追加する必要があることはわかっていますが、機能さ\bせることはできません。

たとえば、名前付きの 2 つの顔文字があり、emotICON常にemotIの画像が表示される場合emotI

これはローダーです:

ReChat.Playback.prototype._loadEmoticons = function() {
  var that = this;
  this._emoticons = [];
  ReChat.get('https://api.twitch.tv/kraken/chat/emoticons', {}, function(result) {
    $.each(result.emoticons, function(i, emoticon) {
      var image = emoticon.images[0];
      if (image.emoticon_set === 27) {
        that._emoticons.push({

          regex: new RegExp(emoticon.regex, 'g'),
          code: $('<span>').addClass('emoticon').css({ 'background-image': 'url(' + image.url + ')', 'height': image.height, 'width': image.width }).prop('outerHTML').replace(/&quot;/g, "'")
        });
      }
    });
  });
};

そして、これは置き換えです:

ReChat.Playback.prototype._replaceEmoticons = function(text) {
    $.each(this._emoticons, function(i, emoticon) {

        text = text.replace(emoticon.regex, emoticon.code);

    });
    return text;
}

ソース コード全体が必要な場合は、https://github.com/pencil/rechatで入手できます。

4

1 に答える 1