always-active icon indicating copy to clipboard operation
always-active copied to clipboard

Character.ai detects inactive tabs

Open omnicron-llc opened this issue 1 year ago • 2 comments

I believe you can test this without signing up - but creating an account is free. The animations during AI chat will pause when the window is not active, so they are using a mechanism this extension doesn't handle.

omnicron-llc avatar Aug 06 '23 22:08 omnicron-llc

It appears that on this page, the combination of "ResizeObserver" and "requestAnimationFrame" is used for rendering. While we do modify "requestAnimationFrame," the browser doesn't refresh the DOM's visual updates when the tab is hidden. As a result, the "ResizeObserver" function isn't triggered.

I'm not sure how we can bypass this

brian-girko avatar Aug 13 '23 06:08 brian-girko

This userscript works on Firefox but not Chromium. I've tried all kind of things on Chromium but I just can't get it to work

(function() {
    'use strict';

    // Override the visibilityState property of the document to always return "visible"
    Object.defineProperty(document, "visibilityState", {value: "visible", writable: false});

    // Override the hidden property of the document to always return false
    Object.defineProperty(document, "hidden", {value: false, writable: false});

    // Override the addEventListener method of the document to prevent visibilitychange events from being registered
    const originalAddEventListener = document.addEventListener;
    document.addEventListener = function(type, listener, options) {
        if (type !== "visibilitychange") {
            originalAddEventListener.call(document, type, listener, options);
        }
    };
})();

Fukitsu avatar Aug 14 '23 02:08 Fukitsu