<commit_before>/// <reference path="../typings/jquery/jquery.d.ts" />
declare var chrome:any;
declare var JST:any;

class EventEmitter {

    private handlers:any = {};

    on(name:string, func:(...values:any[]) => any) {
        if (!this.handlers[name]) this.handlers[name] = [];
        this.handlers[name].push(func);
    }

    off(name?:string, func?:(...values:any[]) => any) {
        if (name === undefined) {
            this.handlers = {};
        } else if (func === undefined) {
            this.handlers[name] = [];
        } else {
            this.handlers[name] = this.handlers[name].filter(
                (handler) => (handler !== func)
            );
        }
    }

    emit(name:string, event?) {
        var handlers = this.handlers[name] || [];
        for (var i = 0, len = handlers.length; i < len; i++) {
            handlers[i](event);
        }
    }
}

interface UrlSet {
    url      : string;
    srcUrl   : string;
    anchorUrl: string;
}

interface URL {
    href: string;
    protocol: string;
    host: string;
    hostname: string;
    port: string;
    pathname: string;
    search: string;
    hash: string;
    username: string;
    password: string;
    origin: string;
    new(url: string): URL;
}

class ImazipURL {
    href: string;
    protocol: string;
    host: string;
    hostname: string;
    port: string;
    pathname: string;
    search: string;
    hash: string;
    username: string;
    password: string;
    origin: string;

    constructor(urlString: string) {
        var url = new URL(urlString);
        // google images
        if (url.hostname + url.pathname === 'www.google.co.jp/imgres') {
            var params = this.parseParams(url);<commit_msg>co.jp 以外の google にも対応(誤爆もある)<commit_after>/// <reference path="../typings/jquery/jquery.d.ts" />
declare var chrome:any;
declare var JST:any;

class EventEmitter {

    private handlers:any = {};

    on(name:string, func:(...values:any[]) => any) {
        if (!this.handlers[name]) this.handlers[name] = [];
        this.handlers[name].push(func);
    }

    off(name?:string, func?:(...values:any[]) => any) {
        if (name === undefined) {
            this.handlers = {};
        } else if (func === undefined) {
            this.handlers[name] = [];
        } else {
            this.handlers[name] = this.handlers[name].filter(
                (handler) => (handler !== func)
            );
        }
    }

    emit(name:string, event?) {
        var handlers = this.handlers[name] || [];
        for (var i = 0, len = handlers.length; i < len; i++) {
            handlers[i](event);
        }
    }
}

interface UrlSet {
    url      : string;
    srcUrl   : string;
    anchorUrl: string;
}

interface URL {
    href: string;
    protocol: string;
    host: string;
    hostname: string;
    port: string;
    pathname: string;
    search: string;
    hash: string;
    username: string;
    password: string;
    origin: string;
    new(url: string): URL;
}

class ImazipURL {
    href: string;
    protocol: string;
    host: string;
    hostname: string;
    port: string;
    pathname: string;
    search: string;
    hash: string;
    username: string;
    password: string;
    origin: string;

    constructor(urlString: string) {
        var url = new URL(urlString);
        // google images
        if (url.hostname.match(/^www\.google\./) && url.pathname === '/imgres') {
            var params = this.parseParams(url);
{'fraction_non_alphanumeric': 0.1523121387283237, 'fraction_numerical': 0.0005780346820809249, 'mean_word_length': 2.109613656783468, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3165156', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1090, 'n_words': 256}