Update ChatGPT script, bump-versions script
This commit is contained in:
parent
b9b9dba524
commit
ca47ee3e30
@ -1,10 +1,10 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Prefix ChatGPT chats with "S:"
|
// @name Prefix ChatGPT chats with "S:"
|
||||||
// @namespace http://tampermonkey.net/
|
// @namespace http://tampermonkey.net/
|
||||||
// @version 2024-11-23
|
// @version 2024-11-23T16:11:30+05:30
|
||||||
// @description For TOTALLY legit usage reasons...
|
// @description For TOTALLY legit usage reasons...
|
||||||
// @author Sangeeth Sudheer
|
// @author Sangeeth Sudheer
|
||||||
// @match https://chatgpt.com/c/*
|
// @match https://chatgpt.com/*
|
||||||
// @icon https://www.google.com/s2/favicons?sz=64&domain=chatgpt.com
|
// @icon https://www.google.com/s2/favicons?sz=64&domain=chatgpt.com
|
||||||
// @updateURL https://git.sangeeth.dev/x/userscripts/raw/branch/main/chatgpt-chat-prefixer/ChatGPTChatPrefixer.user.js
|
// @updateURL https://git.sangeeth.dev/x/userscripts/raw/branch/main/chatgpt-chat-prefixer/ChatGPTChatPrefixer.user.js
|
||||||
// @downloadURL https://git.sangeeth.dev/x/userscripts/raw/branch/main/chatgpt-chat-prefixer/ChatGPTChatPrefixer.user.js
|
// @downloadURL https://git.sangeeth.dev/x/userscripts/raw/branch/main/chatgpt-chat-prefixer/ChatGPTChatPrefixer.user.js
|
||||||
@ -17,7 +17,7 @@
|
|||||||
const PREFIX = "S: ";
|
const PREFIX = "S: ";
|
||||||
|
|
||||||
const sels = {
|
const sels = {
|
||||||
activeChatSidebarItem: '[data-testid^="history-item"]:has(> [class*="active"])',
|
activeChatSidebarItem: '[data-testid^="history-item"]:has(> [class~="bg-token-sidebar-surface-secondary"])',
|
||||||
renamePopoverItem: '[data-testid="share-chat-menu-item"] + div',
|
renamePopoverItem: '[data-testid="share-chat-menu-item"] + div',
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,17 +60,20 @@
|
|||||||
_wait();
|
_wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
let isRunning = false;
|
async function getStableLabelText(el) {
|
||||||
|
while (true) {
|
||||||
|
const prev = el.textContent.trim();
|
||||||
|
await wait(1000);
|
||||||
|
const curr = el.textContent.trim();
|
||||||
|
|
||||||
|
if (prev === curr) {
|
||||||
|
return curr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
try {
|
try {
|
||||||
if (isRunning) {
|
|
||||||
console.log("Script already running");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
isRunning = true;
|
|
||||||
|
|
||||||
const menuItem = document.querySelector(sels.activeChatSidebarItem);
|
const menuItem = document.querySelector(sels.activeChatSidebarItem);
|
||||||
|
|
||||||
if (!menuItem) {
|
if (!menuItem) {
|
||||||
@ -78,7 +81,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const label = menuItem.querySelector("a").textContent.trim();
|
const label = await getStableLabelText(menuItem.querySelector("a"));
|
||||||
|
|
||||||
if (/new chat/i.test(label)) {
|
if (/new chat/i.test(label)) {
|
||||||
console.log("Chat label isn't yet autopopulated by LLM");
|
console.log("Chat label isn't yet autopopulated by LLM");
|
||||||
@ -91,16 +94,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
triggerEnterKey(menuItem.querySelector("button"));
|
triggerEnterKey(menuItem.querySelector("button"));
|
||||||
await wait(500);
|
await wait(100);
|
||||||
|
|
||||||
document.querySelector(sels.renamePopoverItem).click();
|
document.querySelector(sels.renamePopoverItem).click();
|
||||||
await wait(2000);
|
await wait(500);
|
||||||
|
|
||||||
const input = menuItem.querySelector("input");
|
const input = menuItem.querySelector("input");
|
||||||
const prevValue = input.value;
|
const prevValue = input.value;
|
||||||
|
|
||||||
input.focus();
|
input.focus();
|
||||||
await wait(500);
|
await wait(100);
|
||||||
|
|
||||||
input.value = `${PREFIX}${label}`;
|
input.value = `${PREFIX}${label}`;
|
||||||
|
|
||||||
@ -112,15 +115,15 @@
|
|||||||
input.dispatchEvent(inputEvent);
|
input.dispatchEvent(inputEvent);
|
||||||
|
|
||||||
triggerEnterKey(input);
|
triggerEnterKey(input);
|
||||||
await wait(500);
|
await wait(100);
|
||||||
|
|
||||||
console.log("Renamed chat");
|
console.log("Renamed chat");
|
||||||
isRunning = false;
|
|
||||||
} finally {
|
} finally {
|
||||||
isRunning = false;
|
setTimeout(main, 5000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
setInterval(main, 5000);
|
setTimeout(main, 5000);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
@ -4,4 +4,4 @@ script=$1
|
|||||||
|
|
||||||
echo $script
|
echo $script
|
||||||
|
|
||||||
find . -name "$script" -exec sed -i '' -e "s=\(// @version[ ]*\).*=\\1$(date -I'seconds')=g" {} \;
|
find . -iname "*$script*.user.js" -type f -exec sed -i '' -e "s=\(// @version[ ]*\).*=\\1$(date -I'seconds')=g" {} \;
|
||||||
|
Loading…
Reference in New Issue
Block a user