c.Ai Search Expander

Automatically expands search results on c.Ai

当前为 2024-07-09 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name c.Ai Search Expander
  3. // @namespace https://greasyfork.org/users/1084087-fermion
  4. // @version 1.0
  5. // @description Automatically expands search results on c.Ai
  6. // @author ashley
  7. // @match https://character.ai/*
  8. // @icon https://c.ai/static/images/favicon.ico
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. function expandSearchResults() {
  17. const loadMoreButton = document.querySelector('.search-load-more');
  18. if (loadMoreButton) {
  19. loadMoreButton.click();
  20. setTimeout(expandSearchResults, 500); // Wait 0.5 seconds before checking again
  21. }
  22. }
  23.  
  24. // Wait for the search results to appear, then start expanding them
  25. const observer = new MutationObserver((mutations) => {
  26. mutations.forEach((mutation) => {
  27. if (mutation.type === 'childList' && document.querySelector('.search-load-more')) {
  28. expandSearchResults();
  29. observer.disconnect(); // Stop observing once we've started expanding
  30. }
  31. });
  32. });
  33.  
  34. observer.observe(document.body, { childList: true });
  35. })();