adamlui / autoclear-chatgpt-history

🕶️ Adds chat auto-clear functionality to ChatGPT for more privacy
https://autoclearchatgpt.com
Other
44 stars 6 forks source link

no longer works, neither gui nor functionality #58

Open schmorp opened 2 weeks ago

schmorp commented 2 weeks ago

For a few days, neither the user interface shows up nor does it delete any chats. Mode change notifications work, as well as toggling autoclear and visibility (but neither has any effect).

It worked fine before that, and I am not aware of changing anything. I do not know if this happened before or after I updated to the latest userscript version, so it could be something that changed in chatgpt's side (or possibly a browser update).

There is nothing suspicious in the console output either - the script clearly is loaded, but it doesn't do anything.

adamlui commented 2 weeks ago

hey @schmorp OpenAi has been changing the HTML for the last few days constantly breaking my scripts for no good reason which I spent all day yesterday fixing, but they changed something again that did not improve anything at all today, so I have to fix everything all over again when I am not busy

adamlui commented 2 weeks ago

@schmorp actually it works for me, can you tell me the userscript and browser you're using, also Autoclear ChatGPT History version

dliedke commented 1 week ago

Same issue here

dliedke commented 1 week ago

If I comment the two lines with await it works. It is chatgpt.isLoaded() and chatgpt.sidebar.isLoaded() that is not working:

 // Init UI flags
//await Promise.race([chatgpt.isLoaded(), new Promise(resolve => setTimeout(resolve, 5000))]) // initial UI loaded
//await chatgpt.sidebar.isLoaded()
const isFirefox = chatgpt.browser.isFirefox(),
      isGPT4oUI = document.documentElement.className.includes(' '),
      firstLink = chatgpt.getNewChatLink()
dliedke commented 1 week ago

These is working code for chatgpt.isLoaded() and chatgpt.sidebar.isLoaded() methods in chatgpt.js library that should be updated.

Thanks!


await Promise.race([isLoaded(), new Promise(resolve => setTimeout(resolve, 5000))]) // initial UI loaded
await sidebarIsLoaded();

 function isLoaded() {
        return new Promise(resolve => {
            const checkLoaded = () => {
                // Check for the main content area
                const mainContent = document.querySelector('main');
                if (mainContent) {
                    // Check for the chat input area
                    const chatInput = document.querySelector('form textarea');
                    if (chatInput) {
                        resolve(true);
                        return;
                    }
                }
                // If not loaded, check again after a short delay
                setTimeout(checkLoaded, 100);
            };
            checkLoaded();
        });
    }

  async function sidebarIsLoaded() {
        await isLoaded();
        return new Promise(resolve => {
            const checkSidebar = () => {
                // Get all buttons matching the criteria
                const buttons = document.querySelectorAll('button.text-token-text-secondary svg[width="24"][height="24"]');

                // Check if we have at least two buttons and focus on the second one
                if (buttons.length >= 2) {
                    const newChatButton = buttons[1].closest('button');
                    if (newChatButton) {
                        // Verify the SVG path to ensure it's the correct button
                        const svgPath = newChatButton.querySelector('path');
                        if (svgPath && svgPath.getAttribute('d').startsWith('M15.6729 3.91287')) {
                            resolve(true);
                            return;
                        }
                    }
                }
                // If not loaded, check again after a short delay
                setTimeout(checkSidebar, 100);
            };
            checkSidebar();
        });
    }
adamlui commented 1 week ago

Hey @dliedke actually I just updated them to use mutation observers for improved efficiency but re: chatgpt.isLoaded() I see you changed to using chatbar instead of chat button. Can you paste chatgpt.js into your console and confirm chatgpt.getNewChatBtn() no longer works for you? (if so I'd like to know the updated selector since my UI is still the old one)

adamlui commented 1 week ago

Also can you confirm whether chatgpt.getNewChatLink() still works

adamlui commented 1 week ago

Your sidebarIsLoaded() doesn't work for me because the button is not always a pencil icon (in temp chat for example) is why the original getNewChatLink() { return document.querySelector('nav a[href="/"]'); } was ideal, so if you can confirm this selector still works then something else is different

dliedke commented 1 week ago

Sure, it is just a proposal, I am not the developer for this project.

Appreciate this autoclear project, it is very good and I had to fix myself to keep it working.

Thanks,

Daniel

adamlui commented 1 week ago

@dliedke i still want to add you as contributor, do you think you can test if chatgpt.getNewChatLink() still works by pasting chatgpt.js into console and typing the function? (This will be helpful to update for users of old UI like me and new UI like you)

dliedke commented 1 week ago

document.querySelector('nav a[href="/"]');

image

adamlui commented 1 week ago

I'm stumped why commenting out the two lines for you fixes it, because both do promise race and time out after 5s so even if selector is outdated script should've proceeded

dliedke commented 1 week ago

Seems it was never returning or timing out, but I can't be sure

adamlui commented 1 week ago

Does this work for you?

function getNewChatButton() {
    for (const navBtnSVG of document.querySelectorAll('nav button svg'))
        if (navBtnSVG.querySelector('path[d^="M15.6729"], '  // pencil-on-pad icon
                                  + 'path[d^="M3.06957"]'))  // refresh icon if temp chat
            return navBtnSVG.parentNode;
}
dliedke commented 1 week ago

image It finds 5 elements

adamlui commented 1 week ago

Can you copy/paste the entire https://github.com/KudoAI/chatgpt.js/blob/main/chatgpt.js in console

Then

chatgpt.isLoaded().then(() => alert('chatgpt.isLoaded() works'))

and

chatgpt.sidebar.isLoaded().then(() => alert('chatgpt.sidebar.isLoaded() works'))

do they alert

dliedke commented 1 week ago

yes

adamlui commented 1 week ago

Can you refresh then paste the old https://github.com/KudoAI/chatgpt.js/blob/ee4505c1b476a160a5a191037449f363748946c8/chatgpt.js that didn't use mutation observers, do they still both alert

dliedke commented 1 week ago

looks good

adamlui commented 1 week ago

Wait can you patse the chatgpt.js used by Autoclear https://cdn.jsdelivr.net/npm/@kudoai/chatgpt.js@3.1.0/dist/chatgpt.min.js do they both still alert

dliedke commented 1 week ago

yes

adamlui commented 1 week ago

How about the lines you commented out

(async () => {
    await Promise.race([chatgpt.isLoaded(), new Promise(resolve => setTimeout(resolve, 5000))]) // initial UI loaded
    await chatgpt.sidebar.isLoaded()
    alert('sidebar loaded')
})()
dliedke commented 1 week ago

image

Yes, I can rollback my changes and test again here the script.

adamlui commented 1 week ago

here's the latest code https://github.com/adamlui/autoclear-chatgpt-history/blob/main/greasemonkey/autoclear-chatgpt-history.user.js that uses the chatgpt.min.js you tested

dliedke commented 1 week ago

nice, working fine. thanks!

adamlui commented 1 week ago

@schmorp does it work for u too?