codecollabspace / chatgpt_citations

A browser extension designed to generate BibTeX citations from chat conversations in OpenAI's ChatGPT interface.
MIT License
0 stars 0 forks source link

Titlebar children is undefined #18

Closed officialbishowb closed 9 months ago

officialbishowb commented 9 months ago

titleBar.children[1] is undefined

image

function getGPTver() {
    let titleBar = document.querySelector('div[class="sticky top-0 mb-1.5 flex items-center justify-between z-10 h-14 bg-white p-2 font-semibold dark:bg-gray-800"]');

    let gptVer = titleBar.children[1].children[0].children[0].innerText;

    if (!gptVer) {
        let gptName = document.querySelector('div[class="group flex cursor-pointer items-center gap-1 rounded-xl py-2 px-3 text-lg font-medium hover:bg-gray-50 radix-state-open:bg-gray-50 dark:hover:bg-black/10 dark:radix-state-open:bg-black/20"]');

        return gptName.innerText;
    }

    return gptVer
}

Probably check if titleBar is null or not and proceed accordingly because the element has probably been removed.