// ==UserScript== // @name c.AI Search Sort // @author EnergoStalin // @description Sort search so cards with public definition stays on top and marked with a star // @license AGPL-3.0-only // @version 1.1.0 // @namespace https://c.ai // @match https://character.ai/* // @run-at document-body // @icon https://www.google.com/s2/favicons?sz=64&domain=character.ai // @grant GM.addStyle // @downloadURL none // ==/UserScript== (async () => { var y=Object.defineProperty;var o=(t,e)=>y(t,"name",{value:e,configurable:!0});async function a(t,e=1e4,n=1e3){return new Promise((i,r)=>{let l=e,s=setInterval(async()=>{let c=await t();l-=n,l<=0&&(clearInterval(s),r()),c&&(clearInterval(s),i(c))},n)})}o(a,"waitNotNull");function p(t){let e=unsafeWindow.location.href;new MutationObserver(()=>{e!==unsafeWindow.location.href&&(e=unsafeWindow.location.href,t(e))}).observe(unsafeWindow.document.body,{subtree:!0,childList:!0}),t(e)}o(p,"injectNavigationHook");var q=await a(()=>document.querySelector("#__NEXT_DATA__")?.textContent).then(t=>JSON.parse(t).props.pageProps),T=q.token;async function d(t){return await fetch("https://plus.character.ai/chat/character/info/",{headers:{Authorization:`Token ${T}`,Origin:"https://character.ai/",Referer:"https://character.ai/","Content-Type":"application/json",Accept:"application/json"},method:"POST",body:JSON.stringify({external_id:t})}).then(e=>e.json()).then(e=>e.character)}o(d,"getCharacterInfo");GM.addStyle(` .tooltip{position:relative;cursor:pointer}.tooltip .tooltip-text{visibility:hidden;text-align:left;z-index:1;opacity:0;transition:opacity .3s;font-size:.7em;color:#a6a6a6;text-wrap:nowrap}.tooltip .tooltip-head{text-align:center;font-size:1.3em;color:#a6a6a6}.tooltip .tooltip-even{flex-basis:50%}.tooltip .tooltip-number{color:#b0a676;text-align:right}.tooltip:hover .tooltip-text{visibility:visible;opacity:1} `);GM.addStyle(` .align-items-start{align-items:flex-start} `);var f='',u='';function h(t){t.querySelector("div[data-status]")?.remove()}o(h,"clearStatus");function v(t,e){let n=document.createElement("div");return n.dataset.status=e,n.classList.add("flex","flex-col","tooltip"),t.classList.add("align-items-start"),t.append(n),n}o(v,"statusWrapper");function m(t){return!!t.querySelector('div[data-status="starred"]')}o(m,"isStarred");function x(t,e){v(t,"starred").innerHTML=`