Hide c.ai

Hide censorship warning, ads, call button from c.ai

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, Greasemonkey alebo Violentmonkey.

Na inštaláciu tohto skriptu budete musieť nainštalovať rozšírenie, ako je napríklad Tampermonkey alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey alebo Userscripts.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie správcu používateľských skriptov.

(Už mám správcu používateľských skriptov, nechajte ma ho nainštalovať!)

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

(Už mám správcu používateľských štýlov, nechajte ma ho nainštalovať!)

// ==UserScript==
// @name         Hide c.ai
// @version      2.5.1
// @match        *://character.ai/*
// @grant        none
// @license      WTFPL
// @description  Hide censorship warning, ads, call button from c.ai
// @namespace    hidecai
// ==/UserScript==

(function() {
  'use strict';

  const MULTI_SELECTORS = [
    // censorship warning
    '.border-error',
    // ads title
    '.mx-4.mb-1.justify-between.flex',
    // ads body
    '.text-\\[\\#F3F3F3\\].w-full.justify-center.flex',
    // ads body type 2
    '.rounded-\\[20px\\]',
    // Google ads
    '[data-google-query-id]'
  ];

  const SINGLE_SELECTORS = [
    // call
    '.bg-background.rounded-md.inline-flex:not(.ml-2)',
    // sidebar
    '.no-underline.tap-highlight-transparent:nth-of-type(2)',
    '.no-underline.tap-highlight-transparent:nth-of-type(3)',
    '.no-underline.tap-highlight-transparent:nth-of-type(4)',
    // bottom warning
    '.-mt-2.justify-center.items-center.flex.relative',
    // background warning
    '.bg-warning\\/20.max-w-\\[340px\\].flex',
    // ads banner
    '.bg-\\[var\\(--G50\\)\\].items-center.justify-center.flex.w-full',
    //'.justify-center .transition-opacity',
    '.h-svh > .w-full',
    // ads fullscreen banner
    '.fixed.z-50.grid.bg-\\[\\#131313\\]',
    // ads fullscreen banner layer
    '.inset-0.z-50',
    // search right side bar
    '.\\32 xl\\:w-\\[380px\\]',
  ];

  function clickCloseButton() {
    const closeBtn = document.querySelector(
        '[role="dialog"] button[aria-label="Close"].bg-\\[\\#333333\\]\\/75'
    );
    if (closeBtn) closeBtn.click();
  }

  function hideSearchAdsTitle() {
    document.querySelectorAll('p.text-xs.font-medium.leading-normal').forEach(p => {
      if (p.textContent.trim() === 'Advertisement') {
        const container = p.closest('.p-2');
        if (container) container.style.display = 'none';
      }
    });
  }

  function hideUpgradeTo() {
    document.querySelectorAll('button').forEach(btn => {
      if (btn.textContent.trim().startsWith('Upgrade to')) {
        const container = btn.closest('.flex.flex-col') || btn.parentElement;
        if (container) container.style.display = 'none';
      }
    });
  }

  function hideElements() {
    MULTI_SELECTORS.forEach(sel =>
      document.querySelectorAll(sel).forEach(el => el.style.display = 'none')
    );
    SINGLE_SELECTORS.forEach(sel => {
      const el = document.querySelector(sel);
      if (el) el.style.display = 'none';
    });
    hideSearchAdsTitle();
    hideUpgradeTo();
    clickCloseButton();
  }

  window.addEventListener('load', hideElements);
  new MutationObserver(hideElements).observe(document.body, {
    childList: true,
    subtree: true,
  });
})();