<commit_before>import { main, createProps } from './filter/index';

function isOnInvalidPath() {
    const pathname = location.pathname;
    const firstLinkHref = document.querySelector('link').href;

    const isNotGithubPage = /^(https:\/\/).*\/assets\/frameworks\-.*/.test(firstLinkHref) === false;
    const hasNoFilterOnPage = /(.*)\/(.*)\/(issues|pulls)/.test(pathname) === false;

    return isNotGithubPage || hasNoFilterOnPage;
}

function isAlreadyInitialized() {
    return document.getElementById('__filterInputWrap') !== null;
}

function run(main, el) {
    if (isOnInvalidPath() || isAlreadyInitialized()) {
        return;
    }

    const props = createProps(el);
    const { DOM } = main(props);

    DOM.subscribe();
}

;(function ready(fn) {
    if (document.readyState != 'loading'){
        fn();
    } else {
        document.addEventListener('DOMContentLoaded', fn);
    }
})(() => {
    const runner = run.bind(null, main, document);
    chrome.extension.onMessage.addListener(runner);
    runner.call(this);
});<commit_msg>fix(-): check if select element is ready before an app is initizlied<commit_after>import { main, createProps } from './filter/index';

function isOnInvalidPath() {
    const pathname = location.pathname;
    const firstLinkHref = document.querySelector('link').href;

    const isNotGithubPage = /^(https:\/\/).*\/assets\/frameworks\-.*/.test(firstLinkHref) === false;
    const hasNoFilterOnPage = /(.*)\/(.*)\/(issues|pulls)/.test(pathname) === false;

    return isNotGithubPage || hasNoFilterOnPage;
}

function isAlreadyInitialized() {
    return document.getElementById('__filterInputWrap') !== null;
}

function isDomNotReady() {
    return document.querySelector('.subnav-spacer-right .select-menu-list') === null;
}

function shouldBlockInitialize() {
    return isOnInvalidPath()
    || isAlreadyInitialized()
    || isDomNotReady();
}

function run(main, el) {
    if (shouldBlockInitialize()) {
        return;
    }

    const props = createProps(el);
    const { DOM } = main(props);

    DOM.subscribe();
}

;(function ready(fn) {
    if (document.readyState != 'loading'){
        fn();
    } else {
        document.addEventListener('DOMContentLoaded', fn);
    }
})(() => {
    const runner = run.bind(null, main, document);
    chrome.extension.onMessage.addListener(runner);
    runner.call(this);
});
{'fraction_non_alphanumeric': 0.16624472573839663, 'fraction_numerical': 0.0, 'mean_word_length': 3.603883495145631, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1909661', 'n_tokens_mistral': 735, 'n_tokens_neox': 720, 'n_words': 140}