Last active
November 3, 2025 19:25
-
-
Save jhauga/90ccd5e537c2bd08e5a9427c82d437ae to your computer and use it in GitHub Desktop.
Bookmarklet - use this bookmarklet for searching titles of chat history when chat history gets long. Ensure to copy/paste the top condensed line of the bookmarklet. Info at "https://github.com/isocialPractice/bookmarklets".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// *********************************************************** /// | |
| // ****************** BROWSER BOOKMARKLET GIST ***************** // | |
| // ************************************************************* // | |
| // // | |
| // LICENSE ///////////////////////////////////////////////////// | |
| // ******* // | |
| // The code in this gist is public domain. // | |
| // Licensed as Public Domain CC0 // | |
| ////////////////////////////////////////////////////////////////// | |
| // | |
| // COPY / PAST BELOW LINE TO USE | |
| javascript:(function() { /* DOM variables. */ var bodyChatGPTSearchChatHistory = /* to insert style after */ document.getElementsByTagName("body"); var historyChatGPTSearchChatHistory = /* chat history parent */ document.getElementById("history"); /* Create variables. */ var searchParChatGPTSearchChatHistory = /* parent for search */ document.createElement("div"); var searchChatGPTSearchChatHistory = /* search through chat history */ document.createElement("input"); var clearChatGPTSearchChatHistory = /* clear search element */ document.createElement("span"); /* Global variables defined later. */ var historyTagChatGPTSearchChatHistory, historyTagChatGPTSearchChatHistoryLen, searchIDChatGPTSearchChatHistory, searchParIDChatGPTSearchChatHistory, clearIDChatGPTSearchChatHistory; /* Create raw html to insert */ var styleChatGPTSearchChatHistory = ` <style> /* fix search box */ div#searchParChatGPTSearchChatHistory { position: fixed; top: 195px; z-index: 100; padding-top: 5px; } div#searchParChatGPTSearchChatHistory + div { margin-top: 20px; } /* search style */ input.searchHistoryChatGPTSearchChatHistory { color: black; margin-left: 8px; margin-top: 15px; } /* hover search */ input.searchHistoryChatGPTSearchChatHistory:hover { border: 1px solid darkslategrey; } /* clear style */ span.clearChatGPTSearchChatHistory { cursor: pointer; margin-left: 5px; padding: 3px 3px 7px; border: 1px solid white; border-radius: 25px; } /* hover clear */ span.clearChatGPTSearchChatHistory:hover { border: 3px solid white; font-weight: bold; } </style> `; /* Debug variables. */ var debugChatGPTSearchChatHistory = 0; /* 0 (default) 1 console.log()s */ /******************************** SUPPORT FUNCTIONS ********************************/ /* Define variables for chat history, allowing updated list with search. */ var initDefineChatGPTSearchChatHistory = 0; /* ensure elements are ready */ const defineHistoryChatGPTSearchChatHistory = () => { historyTagChatGPTSearchChatHistory = /* separate chat history */ historyChatGPTSearchChatHistory.getElementsByTagName("a"); historyTagChatGPTSearchChatHistoryLen = /* for loop use */ historyTagChatGPTSearchChatHistory.length; /* ensure text color remains constant */ if (initDefineChatGPTSearchChatHistory >= 1) { if (!searchIDChatGPTSearchChatHistory) { /* define if by change not */ /* define forward declared global */ searchIDChatGPTSearchChatHistory = /* variable for search input */ document.getElementById("searchHistoryChatGPTSearchChatHistory"); } if (!clearIDChatGPTSearchChatHistory) { /* define if by change not */ /* define forward declared global */ clearIDChatGPTSearchChatHistory = /* varaible for clearing search */ document.getElementById("clearChatGPTSearchChatHistory"); } /* ensure text color to black */ if ( searchIDChatGPTSearchChatHistory.style.color != "black" ) searchIDChatGPTSearchChatHistory.style.color = "black"; /* ensure border is set */ if ( clearIDChatGPTSearchChatHistory.style.border != "1px solid white" ) clearIDChatGPTSearchChatHistory.style.border = "1px solid white"; } else { initDefineChatGPTSearchChatHistory++; } }; defineHistoryChatGPTSearchChatHistory(); /* call and intial define chats */ /* Create the html elements of search above the chat history on left navbar. */ const createHTMLChatGPTSearchChatHistory = () => { /* don't duplicate */ if (!document.getElementById("searchParChatGPTSearchChatHistory")) { /* insert raw style element */ bodyChatGPTSearchChatHistory[0] .insertAdjacentHTML("afterbegin", styleChatGPTSearchChatHistory); /* id to allow variable storage */ searchParChatGPTSearchChatHistory.id = "searchParChatGPTSearchChatHistory"; /* add search element parent */ historyChatGPTSearchChatHistory .insertAdjacentElement("beforebegin", searchParChatGPTSearchChatHistory); /* define forward declared global */ searchParIDChatGPTSearchChatHistory = /* variable for search parent */ document.getElementById("searchParChatGPTSearchChatHistory"); /* add attributes to seach element */ searchChatGPTSearchChatHistory.id = "searchHistoryChatGPTSearchChatHistory"; searchChatGPTSearchChatHistory.className = "searchHistoryChatGPTSearchChatHistory"; searchChatGPTSearchChatHistory.type = "text"; searchChatGPTSearchChatHistory.placeholder = "Search Chat History"; /* insert search element */ searchParIDChatGPTSearchChatHistory .insertAdjacentElement("afterbegin", searchChatGPTSearchChatHistory); /* define forward declared global */ searchIDChatGPTSearchChatHistory = /* variable for search input */ document.getElementById("searchHistoryChatGPTSearchChatHistory"); /* id to allow variable storage */ clearChatGPTSearchChatHistory.id = "clearChatGPTSearchChatHistory"; clearChatGPTSearchChatHistory.className = "clearChatGPTSearchChatHistory"; clearChatGPTSearchChatHistory.innerText = "x"; /* insert clear element */ searchIDChatGPTSearchChatHistory .insertAdjacentElement("afterend", clearChatGPTSearchChatHistory); /* define forward declared global */ clearIDChatGPTSearchChatHistory = /* varaible for clearing search */ document.getElementById("clearChatGPTSearchChatHistory"); } else { /* do nothing */ let skip; } }; /* Take search input and apply to history, hiding non-matching searches. */ const runSearchChatGPTSearchChatHistory = () => { defineHistoryChatGPTSearchChatHistory(); /* call and redefine chats */ /* check if current search value matches chat history */ for (i = 0; i < historyTagChatGPTSearchChatHistoryLen; i++) { let val = /* current input for search */ searchIDChatGPTSearchChatHistory.value; val = val.toLowerCase(); /* easier search */ let lowCaseChats = /* easier search */ historyTagChatGPTSearchChatHistory[i].textContent.toLowerCase(); /* for debugging - ensure val is correct */ if (debugChatGPTSearchChatHistory == 1) { console.log(val); } /* if chat has contents of search */ if (lowCaseChats.indexOf(val) > -1) { historyTagChatGPTSearchChatHistory[i].style.display = /* show */ ""; } else { historyTagChatGPTSearchChatHistory[i].style.display = /* hide */ "none"; } } }; /* Clear search results. */ const runClearChatGPTSearchChatHistory = () => { searchIDChatGPTSearchChatHistory.value = ""; /* clear search */ /* delay a bit */ setTimeout(function() { runSearchChatGPTSearchChatHistory(); /* show chat history */ }, 100); }; /*********************************************************************************** MAIN FUNCTION ***********************************************************************************/ function createChatGPTSearchChatHistory() { /* create the search elements */ createHTMLChatGPTSearchChatHistory(); /* delay ensuring element creation */ setTimeout(function() { /* add to search element */ searchIDChatGPTSearchChatHistory.addEventListener( "input", /* whenever search field has input */ runSearchChatGPTSearchChatHistory /* show hide accordingly */ ); /* add to clear element */ clearIDChatGPTSearchChatHistory.addEventListener( "click", runClearChatGPTSearchChatHistory ); }, 500); } /* Call main function. */ createChatGPTSearchChatHistory();})(); | |
| // MAKE ANY EDITS AS NEEDED | |
| // ************************************************************* | |
| // Use the JS Formatted Bookmarklet below to see if any changes | |
| // need to be made in accordance to the page you want to use | |
| // it for. After making needed changes ensure that the revised | |
| // bookmarklet is condensed before using it in your browser. | |
| // For more info on this bookmarklet visit: | |
| // https://github.com/isocialPractice/bookmarklets | |
| // ************************************************************* | |
| // ************************************************************* | |
| // ************************JS-FORMATTED************************* | |
| javascript:(function() { | |
| /* DOM variables. */ | |
| var bodyChatGPTSearchChatHistory = /* to insert style after */ | |
| document.getElementsByTagName("body"); | |
| var historyChatGPTSearchChatHistory = /* chat history parent */ | |
| document.getElementById("history"); | |
| /* Create variables. */ | |
| var searchParChatGPTSearchChatHistory = /* parent for search */ | |
| document.createElement("div"); | |
| var searchChatGPTSearchChatHistory = /* search through chat history */ | |
| document.createElement("input"); | |
| var clearChatGPTSearchChatHistory = /* clear search element */ | |
| document.createElement("span"); | |
| /* Global variables defined later. */ | |
| var historyTagChatGPTSearchChatHistory, historyTagChatGPTSearchChatHistoryLen, | |
| searchIDChatGPTSearchChatHistory, searchParIDChatGPTSearchChatHistory, | |
| clearIDChatGPTSearchChatHistory; | |
| /* Create raw html to insert */ | |
| var styleChatGPTSearchChatHistory = ` | |
| <style> | |
| /* fix search box */ | |
| div#searchParChatGPTSearchChatHistory { | |
| position: fixed; | |
| top: 195px; | |
| z-index: 100; | |
| padding-top: 5px; | |
| } | |
| div#searchParChatGPTSearchChatHistory + div { | |
| margin-top: 20px; | |
| } | |
| /* search style */ | |
| input.searchHistoryChatGPTSearchChatHistory { | |
| color: black; | |
| margin-left: 8px; | |
| margin-top: 15px; | |
| } | |
| /* hover search */ | |
| input.searchHistoryChatGPTSearchChatHistory:hover { | |
| border: 1px solid darkslategrey; | |
| } | |
| /* clear style */ | |
| span.clearChatGPTSearchChatHistory { | |
| cursor: pointer; | |
| margin-left: 5px; | |
| padding: 3px 3px 7px; | |
| border: 1px solid white; | |
| border-radius: 25px; | |
| } | |
| /* hover clear */ | |
| span.clearChatGPTSearchChatHistory:hover { | |
| border: 3px solid white; | |
| font-weight: bold; | |
| } | |
| </style> | |
| `; | |
| /* Debug variables. */ | |
| var debugChatGPTSearchChatHistory = 0; /* 0 (default) 1 console.log()s */ | |
| /******************************** SUPPORT FUNCTIONS ********************************/ | |
| /* Define variables for chat history, allowing updated list with search. */ | |
| var initDefineChatGPTSearchChatHistory = 0; /* ensure elements are ready */ | |
| const defineHistoryChatGPTSearchChatHistory = () => { | |
| historyTagChatGPTSearchChatHistory = /* separate chat history */ | |
| historyChatGPTSearchChatHistory.getElementsByTagName("a"); | |
| historyTagChatGPTSearchChatHistoryLen = /* for loop use */ | |
| historyTagChatGPTSearchChatHistory.length; | |
| /* ensure text color remains constant */ | |
| if (initDefineChatGPTSearchChatHistory >= 1) { | |
| if (!searchIDChatGPTSearchChatHistory) { /* define if by change not */ | |
| /* define forward declared global */ | |
| searchIDChatGPTSearchChatHistory = /* variable for search input */ | |
| document.getElementById("searchHistoryChatGPTSearchChatHistory"); | |
| } | |
| if (!clearIDChatGPTSearchChatHistory) { /* define if by change not */ | |
| /* define forward declared global */ | |
| clearIDChatGPTSearchChatHistory = /* varaible for clearing search */ | |
| document.getElementById("clearChatGPTSearchChatHistory"); | |
| } | |
| /* ensure text color to black */ | |
| if ( | |
| searchIDChatGPTSearchChatHistory.style.color != "black" | |
| ) searchIDChatGPTSearchChatHistory.style.color = "black"; | |
| /* ensure border is set */ | |
| if ( | |
| clearIDChatGPTSearchChatHistory.style.border != "1px solid white" | |
| ) clearIDChatGPTSearchChatHistory.style.border = "1px solid white"; | |
| } else { | |
| initDefineChatGPTSearchChatHistory++; | |
| } | |
| }; | |
| defineHistoryChatGPTSearchChatHistory(); /* call and intial define chats */ | |
| /* Create the html elements of search above the chat history on left navbar. */ | |
| const createHTMLChatGPTSearchChatHistory = () => { | |
| /* don't duplicate */ | |
| if (!document.getElementById("searchParChatGPTSearchChatHistory")) { | |
| /* insert raw style element */ | |
| bodyChatGPTSearchChatHistory[0] | |
| .insertAdjacentHTML("afterbegin", styleChatGPTSearchChatHistory); | |
| /* id to allow variable storage */ | |
| searchParChatGPTSearchChatHistory.id = "searchParChatGPTSearchChatHistory"; | |
| /* add search element parent */ | |
| historyChatGPTSearchChatHistory | |
| .insertAdjacentElement("beforebegin", searchParChatGPTSearchChatHistory); | |
| /* define forward declared global */ | |
| searchParIDChatGPTSearchChatHistory = /* variable for search parent */ | |
| document.getElementById("searchParChatGPTSearchChatHistory"); | |
| /* add attributes to seach element */ | |
| searchChatGPTSearchChatHistory.id = "searchHistoryChatGPTSearchChatHistory"; | |
| searchChatGPTSearchChatHistory.className = "searchHistoryChatGPTSearchChatHistory"; | |
| searchChatGPTSearchChatHistory.type = "text"; | |
| searchChatGPTSearchChatHistory.placeholder = "Search Chat History"; | |
| /* insert search element */ | |
| searchParIDChatGPTSearchChatHistory | |
| .insertAdjacentElement("afterbegin", searchChatGPTSearchChatHistory); | |
| /* define forward declared global */ | |
| searchIDChatGPTSearchChatHistory = /* variable for search input */ | |
| document.getElementById("searchHistoryChatGPTSearchChatHistory"); | |
| /* id to allow variable storage */ | |
| clearChatGPTSearchChatHistory.id = "clearChatGPTSearchChatHistory"; | |
| clearChatGPTSearchChatHistory.className = "clearChatGPTSearchChatHistory"; | |
| clearChatGPTSearchChatHistory.innerText = "x"; | |
| /* insert clear element */ | |
| searchIDChatGPTSearchChatHistory | |
| .insertAdjacentElement("afterend", clearChatGPTSearchChatHistory); | |
| /* define forward declared global */ | |
| clearIDChatGPTSearchChatHistory = /* varaible for clearing search */ | |
| document.getElementById("clearChatGPTSearchChatHistory"); | |
| } else { | |
| /* do nothing */ | |
| let skip; | |
| } | |
| }; | |
| /* Take search input and apply to history, hiding non-matching searches. */ | |
| const runSearchChatGPTSearchChatHistory = () => { | |
| defineHistoryChatGPTSearchChatHistory(); /* call and redefine chats */ | |
| /* check if current search value matches chat history */ | |
| for (i = 0; i < historyTagChatGPTSearchChatHistoryLen; i++) { | |
| let val = /* current input for search */ | |
| searchIDChatGPTSearchChatHistory.value; | |
| val = val.toLowerCase(); /* easier search */ | |
| let lowCaseChats = /* easier search */ | |
| historyTagChatGPTSearchChatHistory[i].textContent.toLowerCase(); | |
| /* for debugging - ensure val is correct */ | |
| if (debugChatGPTSearchChatHistory == 1) { | |
| console.log(val); | |
| } | |
| /* if chat has contents of search */ | |
| if (lowCaseChats.indexOf(val) > -1) { | |
| historyTagChatGPTSearchChatHistory[i].style.display = /* show */ | |
| ""; | |
| } else { | |
| historyTagChatGPTSearchChatHistory[i].style.display = /* hide */ | |
| "none"; | |
| } | |
| } | |
| }; | |
| /* Clear search results. */ | |
| const runClearChatGPTSearchChatHistory = () => { | |
| searchIDChatGPTSearchChatHistory.value = ""; /* clear search */ | |
| /* delay a bit */ | |
| setTimeout(function() { | |
| runSearchChatGPTSearchChatHistory(); /* show chat history */ | |
| }, 100); | |
| }; | |
| /*********************************************************************************** | |
| MAIN FUNCTION | |
| ***********************************************************************************/ | |
| function createChatGPTSearchChatHistory() { | |
| /* create the search elements */ | |
| createHTMLChatGPTSearchChatHistory(); | |
| /* delay ensuring element creation */ | |
| setTimeout(function() { | |
| /* add to search element */ | |
| searchIDChatGPTSearchChatHistory.addEventListener( | |
| "input", /* whenever search field has input */ | |
| runSearchChatGPTSearchChatHistory /* show hide accordingly */ | |
| ); | |
| /* add to clear element */ | |
| clearIDChatGPTSearchChatHistory.addEventListener( | |
| "click", | |
| runClearChatGPTSearchChatHistory | |
| ); | |
| }, 500); | |
| } | |
| /* Call main function. */ | |
| createChatGPTSearchChatHistory(); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment