什么是CavalryLogger,我需要它吗? [英] What is CavalryLogger and do I need it?

查看:136
本文介绍了什么是CavalryLogger,我需要它吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在对最近接手的网站进行一些优化。我发现了一个我不认识的脚本:
http://static.ak.fbcdn.net/rsrc.php/zo/r/V95Lkt_uLNB.js

I'm doing some optimisation on a site Ive recently taken over. I've found a script I don't recognise: http://static.ak.fbcdn.net/rsrc.php/zo/r/V95Lkt_uLNB.js

这可能是Facebook的事情,并且有一些关键日志记录正在进行(我不太热衷)

It could be a facebook thing, and there's some key logging going on (that Im not too keen on)

毫无疑问,页面加载(87kb)上请求的最大文件是如此,如果我可以没有它,它真的会加快页面加载。

It is without a doubt the largest file being requested on a page load (87kb) so if I can do without it, it'll really speed up the page load.

有谁知道:

A)它是什么

B)它的用途是什么?
C)它的作用

D)我可以不用它吗

Does anyone know:
A) What it is
B) What it's for
C) What it does
D) Can I do without it

推荐答案

好的,所以我查看了这个缩小代码的美化版本,并注意到以下内容:

Okay so I had a look over the beautified version of this minified code and have noted the following:

本身就是一堆效用函数。

By itself these are a bunch of utility functions.

CavalryLogger本身不对此文件做任何事情,因为它不存在,也没有定义。

CavalryLogger doesn't do anything with this file by itself because it doesn't exist, nor is it defined.

有问题的代码reg arding键绑定:

The code in question regarding key binding:

function KeyEventController() {
  copy_properties(this, {
    handlers: {}
  });
  document.onkeyup = this.onkeyevent.bind(this, 'onkeyup');
  document.onkeydown = this.onkeyevent.bind(this, 'onkeydown');
  document.onkeypress = this.onkeyevent.bind(this, 'onkeypress');
}
copy_properties(KeyEventController, {
  instance: null,
  getInstance: function () {
    return KeyEventController.instance || (KeyEventController.instance = new KeyEventController());
  },
  defaultFilter: function (event, a) {
    event = $E(event);
    return KeyEventController.filterEventTypes(event, a) && KeyEventController.filterEventTargets(event, a) && KeyEventController.filterEventModifiers(event, a);
  },
  filterEventTypes: function (event, a) {
    if (a === 'onkeydown') return true;
    return false;
  },
  filterEventTargets: function (event, b) {
    var a = $E(event).getTarget();
    if (DOM.isNode(a, ['input', 'select', 'textarea', 'object', 'embed'])) if (a.type != 'checkbox' && a.type != 'radio' && a.type != 'submit') return false;
    return a.getAttribute('contentEditable') != 'true';
  },
  filterEventModifiers: function (event, a) {
    if (event.ctrlKey || event.altKey || event.metaKey || event.repeat) return false;
    return true;
  },
  registerKey: function (f, a, d, g) {
    if (d === undefined) d = KeyEventController.defaultFilter;
    var b = KeyEventController.getInstance();
    var c = b.mapKey(f);
    if (is_empty(b.handlers)) onleaveRegister(b.resetHandlers.bind(b));
    for (var e = 0; e < c.length; e++) {
      f = c[e];
      if (!b.handlers[f] || g) b.handlers[f] = [];
      b.handlers[f].push({
        callback: a,
        filter: d
      });
    }
  },
  keyCodeMap: {
    '[': [219],
    ']': [221],
    '`': [192],
    LEFT: [KEYS.LEFT, 63234],
    RIGHT: [KEYS.RIGHT, 63235],
    RETURN: [KEYS.RETURN],
    TAB: [KEYS.TAB],
    DOWN: [KEYS.DOWN, 63233],
    UP: [KEYS.UP, 63232],
    ESCAPE: [KEYS.ESC],
    BACKSPACE: [KEYS.BACKSPACE],
    DELETE: [KEYS.DELETE]
  }
});
copy_properties(KeyEventController.prototype, {
  mapKey: function (a) {
    if (typeof (a) == 'number') return [48 + a, 96 + a];
    if (KeyEventController.keyCodeMap[a.toUpperCase()]) return KeyEventController.keyCodeMap[a.toUpperCase()];
    var b = a.toUpperCase().charCodeAt(0);
    return [b];
  },
  onkeyevent: function (i, c) {
    c = $E(c);
    var d = null;
    var g = this.handlers[c.keyCode];
    var b, f, a;
    if (g) for (var h = 0; h < g.length; h++) {
      b = g[h].callback;
      f = g[h].filter;
      try {
        if (!f || f(c, i)) {
          var node = null;
          if (window.Parent && Parent.byTag && c.getTarget) node = Parent.byTag(c.getTarget(), 'a');
          user_action(node, 'key', c);
          a = b(c, i);
          if (a === false) return Event.kill(c);
        }
      } catch (e) {}
    }
    return true;
  },
  resetHandlers: function () {
    this.handlers = {};
  }
});

此代码允许您将键绑定到回调,并包含更多人类可读的公用键名称。以这里的用法为例:

This code lets you bind keys to callbacks, and includes more human readable names for common keys. Take for example the usage here:

KeyEventController.registerKey('ESCAPE', Dialog._handleEscapeKey, a);

注册ESCAPE密钥以使对话框消失。 处理程序默认情况下也是空的,因此在您使用 registerKey 或手动追加之前不会发生任何事情。请注意,这是调用 registerKey 的唯一实例。

The ESCAPE key is registered to make Dialogs go away. handlers is also empty by default, so nothing is going to happen until you use registerKey or append to it manually. Note that this is the only instance of registerKey being called.

它还有很多AJAX实用程序函数。无论如何都无法从你的域发送任何东西到Facebook,因为相同的原始策略(除非你修改了安全权限,但那是你的错)。与Cookie设置相同。

It also has a lot of AJAX utility functions. Can't really send anything to Facebook from your domain anyways because of same origin policy (unless you modified security permissions, but then that's your fault). Same thing with the cookies set.

还有一个历史记录管理器,但它使用的是iFrame,因此无论如何它都无法从您的域中读取它。

There's also a history manger, but it uses an iFrame so it won't be able to read it from your domain anyways.

最后,我找到的类似按钮代码是一个iFrame,所以它不需要JS包含,除非你使用javascript创建iFrame或其他东西。

Finally the like button code I found is an iFrame, so it wouldn't need JS includes unless you were using javascript to create the iFrame or something.

考虑到这一点,我认为你不需要包括所有这些。

With that in mind I don't see the need for you to include all this.

这篇关于什么是CavalryLogger,我需要它吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆