<commit_before>/// <reference path="../content/base.d.ts" />
(function(this: void): void {
  if (!window.VSettings) { return; }
  type Listener = (this: void, e: Event) => void;
  let d: Document | Document["documentElement"] = document
    , script = d.createElement("script") as HTMLScriptElement | Element
    , installer: Listener | null, box: EventTarget
    , secret = "" + ((Math.random() * 1e6 + 1) | 0);
  if (!(script instanceof HTMLScriptElement)) { return; }
  addEventListener("VimiumReg", installer = function(event) {
    const t = event.target;
    if (!(t instanceof Element) || t.getAttribute("data-secret") !== secret) { return; }
    removeEventListener("VimiumReg", installer, true);
    t.removeAttribute("data-secret");
    t.addEventListener("VimiumOnclick", onclick, true);
    box = t;
    installer = null;
  }, true);
  function onclick(event: Event): void {
    (event.target as Element).vimiumHasOnclick = true;
    event.stopPropagation();
  }
  addEventListener("VimiumOnclick", onclick, true);
  function destroy() {
    removeEventListener("VimiumReg", installer, true);
    removeEventListener("VimiumOnclick", onclick, true);
    if (box) {
      box.removeEventListener("VimiumOnclick", onclick, true);
      box = null as never;
    }
    VSettings && (VSettings.onDestroy = null);
  }
  window.VSettings.onDestroy = destroy;
  script.type = "text/javascript";
  let str = func.toString(), appVer = navigator.appVersion.match(<RegExpSearchable<1>> /\bChrom(?:e|ium)\/(\d+)/);
  if (!appVer || +appVer[1] >= BrowserVer.MinEnsureMethodFunction) {
    str = str.replace(<any>(typeof NDEBUG === "undefined" ? /: ?function(?: \w+)?/g : /:function/g), "");
  }
  script.textContent = '"use strict";(' + str + ')(' + secret + ');';
  d = (d as Document).documentElement || d;
  d.insertBefore(script, d.firstChild);
  script.remove();
  VDom.documentReady(function() { box || destroy(); });

function func(this: void, sec: number): void {
const _listen = EventTarget.prototype.addEventListener, toRegister: Element[] = [],
_dispatch = EventTarget.prototype.dispatchEvent, dispatch = _dispatch.call.bind(_dispatch),
_append = document.appendChild, append = _append.call.bind(_append) as (parent: Node, node: Node) => Node,
_removeNode = document.removeChild, removeNode = _removeNode.call.bind(_removeNode),
contains = document.contains.bind(document),
splice = toRegister.splice.bind<Element[], number, number, Element[]>(toRegister),
register = toRegister.push.bind<Element[], Element, number>(toRegister),
CE = CustomEvent, HA = HTMLAnchorElement,
HF = HTMLFormElement, E = typeof Element === "function" ? Element : HTMLElement,
funcToString = Function.prototype.toString, toStringApply = funcToString.apply.bind(funcToString),
apply = _listen.apply.bind(_listen) as (self: EventTarget, args: any) => void,
call = _listen.call.bind(_listen) as (self: EventTarget, ty: string, func?: null | ((e: Event) => void), opts?: boolean) => void,
hooks = {
  toString(this: Function): string {
    const a = this;
    return toStringApply(a === addEventListener ? _listen : a === toString ? funcToString : a, arguments as any);
  },
  addEventListener(this: EventTarget, type: string, listener: EventListenerOrEventListenerObject) {
    const a = this;
    if (type === "click" && listener && !(a instanceof HA || a instanceof HF) && a instanceof E) {
      register(a as Element);
      if (timer === 0) { timer = next(); }
    }
    const len = arguments.length;
    return len === 2 ? call(a, type, listener) : len === 3 ? call(a, type, listener, arguments[2]) : apply(a, arguments as any);
  }
},
{ toString, addEventListener } = hooks
;

let handler = function(this: void): void {
  rel("DOMContentLoaded", handler, true);
  ct(loadTimeout);
  const docEl = document.documentElement as HTMLElement | SVGElement;
  if (!docEl) { return; }
  box = createElement("div");
  box.setAttribute("data-secret", "" + sec);
  append(docEl, box);<commit_msg>extend click: a try: destroy hooks in host<commit_after>/// <reference path="../content/base.d.ts" />
(function(this: void): void {
  if (!window.VSettings) { return; }
  type Listener = (this: void, e: Event) => void;
  let d: Document | Document["documentElement"] = document
    , script = d.createElement("script") as HTMLScriptElement | Element
    , installer: Listener | null, box: EventTarget
    , secret = "" + ((Math.random() * 1e6 + 1) | 0);
  if (!(script instanceof HTMLScriptElement)) { return; }
  addEventListener("VimiumReg", installer = function(event) {
    const t = event.target;
    if (!(t instanceof Element) || t.getAttribute("data-secret") !== secret) { return; }
    removeEventListener("VimiumReg", installer, true);
    t.removeAttribute("data-secret");
    t.addEventListener("VimiumOnclick", onclick, true);
    box = t;
    installer = null;
  }, true);
  function onclick(event: Event): void {
    (event.target as Element).vimiumHasOnclick = true;
    event.stopPropagation();
  }
  addEventListener("VimiumOnclick", onclick, true);
  function destroy() {
    removeEventListener("VimiumReg", installer, true);
    removeEventListener("VimiumOnclick", onclick, true);
    if (box) {
      box.removeEventListener("VimiumOnclick", onclick, true);
      box.dispatchEvent(new CustomEvent("VimiumDestroy", {detail: secret}));
      box = null as never;
    }
    VSettings && (VSettings.onDestroy = null);
  }
  window.VSettings.onDestroy = destroy;
  script.type = "text/javascript";
  let str = func.toString(), appVer = navigator.appVersion.match(<RegExpSearchable<1>> /\bChrom(?:e|ium)\/(\d+)/);
  if (!appVer || +appVer[1] >= BrowserVer.MinEnsureMethodFunction) {
    str = str.replace(<any>(typeof NDEBUG === "undefined" ? /: ?function(?: \w+)?/g : /:function/g), "");
  }
  script.textContent = '"use strict";(' + str + ')(' + secret + ');';
  d = (d as Document).documentElement || d;
  d.insertBefore(script, d.firstChild);
  script.remove();
  VDom.documentReady(function() { box || destroy(); });

function func(this: void, sec: number): void {
const _listen = EventTarget.prototype.addEventListener, toRegister: Element[] = [],
_dispatch = EventTarget.prototype.dispatchEvent, dispatch = _dispatch.call.bind(_dispatch),
_append = document.appendChild, append = _append.call.bind(_append) as (parent: Node, node: Node) => Node,
_removeNode = document.removeChild, removeNode = _removeNode.call.bind(_removeNode),
contains = document.contains.bind(document),
splice = toRegister.splice.bind<Element[], number, number, Element[]>(toRegister),
register = toRegister.push.bind<Element[], Element, number>(toRegister),
CE = CustomEvent, HA = HTMLAnchorElement,
HF = HTMLFormElement, E = typeof Element === "function" ? Element : HTMLElement,
funcToString = Function.prototype.toString, toStringApply = funcToString.apply.bind(funcToString),
apply = _listen.apply.bind(_listen) as (self: EventTarget, args: any) => void,
call = _listen.call.bind(_listen) as (self: EventTarget, ty: string, func?: null | ((e: Event) => void), opts?: boolean) => void,
hooks = {
  toString(this: Function): string {
    const a = this;
    return toStringApply(a === addEventListener ? _listen : a === toString ? funcToString : a, arguments as any);
  },
  addEventListener(this: EventTarget, type: string, listener: EventListenerOrEventListenerObject) {
    const a = this;
    if (type === "click" && listener && !(a instanceof HA || a instanceof HF) && a instanceof E) {
      register(a as Element);
      if (timer === 0) { timer = next(); }
    }
    const len = arguments.length;
    return len === 2 ? call(a, type, listener) : len === 3 ? call(a, type, listener, arguments[2]) : apply(a, arguments as any);
  }
},
{ toString, addEventListener } = hooks
;

let handler = function(this: void): void {
  rel("DOMContentLoaded", handler, true);
  ct(loadTimeout);
  const docEl = document.documentElement as HTMLElement | SVGElement;
  if (!docEl) { return; }
  box = createElement("div");
  box.setAttribute("data-secret", "" + sec);
  call(box, "VimiumDestroy", function(e: CustomEvent): void {
    if (e.detail === "" + sec) {
      EventTarget.prototype.addEventListener === addEventListener && (EventTarget.prototype.addEventListener = _listen);
      Function.prototype.toString === toString && (Function.prototype.toString = toString);
      box = null as never;
    }
  });
  append(docEl, box);
{'fraction_non_alphanumeric': 0.16140935602904416, 'fraction_numerical': 0.0023806689679800024, 'mean_word_length': 4.484334203655353, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1313433', 'n_tokens_mistral': 2520, 'n_tokens_neox': 2509, 'n_words': 646}