Skip to content

Instantly share code, notes, and snippets.

@zudsniper
Last active April 3, 2024 17:49
Show Gist options
  • Save zudsniper/6d900b2422ce83b03d852685836c2b08 to your computer and use it in GitHub Desktop.
Save zudsniper/6d900b2422ce83b03d852685836c2b08 to your computer and use it in GitHub Desktop.
🧶 Custom GPT Instance "AutoExpert" simple timeout helper [old glitchy version]
// ==UserScript==
// @name AutoExpert Dev Tools with Smart Interaction Detection and Auto-Stash
// @namespace https://gh.zod.tf/
// @version 2.0.2
// @description Enhance ChatGPT AutoExpert Dev instance by resetting the inactivity timer only on meaningful interactions and stashing content before timeout.
// @author AutoExpert & zudsniper
// @match https://chat.openai.com/g/g-pTF23RJ6f-autoexpert-dev*
// @grant GM_addStyle
// ==/UserScript==
(function() {
'use strict';
let timeLeft = 600; // 10 minutes
let lastTime = Date.now();
let timerInterval;
let idleTimeSeconds;
let stashIncrementor = 0;
// GUI Styling
GM_addStyle(`
#autoexpert-dev-tools { position: fixed; top: 10px; right: 10px; z-index: 1000; padding: 10px; background-color: #f9f9f9; border: 1px solid #ccc; border-radius: 5px; }
#autoexpert-dev-tools button { margin-right: 5px; }
#chatgpt-timer { color: red; }
#inactivity-alert { display: none; position: fixed; top: 0; left: 0; right: 0; background-color: red; color: white; text-align: center; padding: 10px 0; font-size: 16px; z-index: 1050; animation: pulseAnimation 2s infinite; }
@keyframes pulseAnimation {
0% { opacity: 0.5; }
50% { opacity: 1; }
100% { opacity: 0.5; }
}
`);
// Initialize GUI
const enhancerDiv = document.createElement('div');
enhancerDiv.id = 'autoexpert-dev-tools';
document.body.appendChild(enhancerDiv);
// Inactivity Timer Display
const timerDisplay = document.createElement('span');
timerDisplay.id = 'chatgpt-timer';
timerDisplay.textContent = '10:00';
enhancerDiv.appendChild(timerDisplay);
// Inactivity Alert
const inactivityAlert = document.createElement('div');
inactivityAlert.id = 'inactivity-alert';
inactivityAlert.textContent = 'Inactivity Warning: Your session will expire soon.';
document.body.insertBefore(inactivityAlert, document.body.firstChild);
// Update timer display
const updateTimerDisplay = () => {
const minutes = Math.floor(timeLeft / 60);
const seconds = timeLeft % 60;
timerDisplay.textContent = `${minutes}:${seconds.toString().substring(0,2).padStart(2, '0')}`;
if (timeLeft <= 0) {
inactivityAlert.style.display = 'block';
inactivityAlert.textContent = 'Session expired. Stashing content...';
inactivityAlert.classList.add('expired');
} else if (timeLeft <= 120) {
inactivityAlert.style.display = 'block';
inactivityAlert.textContent = 'Warning: Session will expire soon!';
} else {
inactivityAlert.style.display = 'none';
}
};
// Reset timer on interaction
const resetTimer = () => {
timeLeft = 600;
lastTime = Date.now();
updateTimerDisplay();
};
// Function to format seconds into hh:mm:ss
const formatIdleTime = (seconds) => {
const hours = Math.floor(seconds / 3600);
const minutes = Math.floor((seconds % 3600) / 60);
const remainingSeconds = seconds % 60;
return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${remainingSeconds.toString().substring(0,2).padStart(2, '0')}`;
};
// Function to handle auto-stash
const executeStashCommand = () => {
const promptTextarea = document.getElementById('prompt-textarea');
if (promptTextarea) {
promptTextarea.value = `/stash Auto-stash executed at ${new Date().toISOString()} - Incrementor: ${++stashIncrementor}`;
const sendButton = document.querySelector('[data-testid="send-button"]');
sendButton.click();
}
};
// Countdown function
const countdown = () => {
const currentTime = Date.now();
const deltaTime = (currentTime - lastTime) / 1000; // Calculate the delta time in seconds
lastTime = currentTime; // Update lastTime to the current time
if (timeLeft > 0) {
timeLeft -= deltaTime; // Decrease timeLeft by the elapsed time
updateTimerDisplay();
} else {
clearInterval(timerInterval); // Stop the timer if time has expired
executeStashCommand(); // Auto-stash when time runs out
}
};
// Start the timer
timerInterval = setInterval(countdown, 1000);
// Event listener for user interactions
document.addEventListener('click', function(e) {
if (e.target.matches('[data-testid="send-button"]:not(.disabled), [data-testid="regenerate-button"], [data-testid="stop-button"]')) {
resetTimer();
}
});
document.addEventListener('keydown', function(e) {
if (e.key === 'Enter' && !e.shiftKey && e.target.matches('#prompt-textarea')) {
resetTimer();
}
});
// Focus event to update timer after being away
window.addEventListener('focus', () => {
const elapsed = Math.floor((Date.now() - lastTime) / 1000);
if (elapsed > 0) {
timeLeft = Math.max(0, timeLeft - elapsed);
}
updateTimerDisplay();
lastTime = Date.now();
});
})();
// ==UserScript==
// @name AutoExpert Dev Tools with Smart Interaction Detection
// @namespace https://gh.zod.tf/
// @version 1.3.1
// @description Enhance ChatGPT AutoExpert Dev instance by resetting the inactivity timer only on meaningful interactions.
// @author AutoExpert & zudsniper
// @match https://chat.openai.com/g/g-pTF23RJ6f-autoexpert-dev*
// @grant GM_addStyle
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_deleteValue
// ==/UserScript==
(function() {
'use strict';
let timeLeft = 600; // 10 minutes
let preTimeoutStashTrigger;
let stashIncrementor = 0;
// GUI Styling
const guiStyles = `
#autoexpert-dev-tools { position: fixed; top: 10px; right: 10px; z-index: 1000; padding: 10px; background-color: #f9f9f9; border: 1px solid #ccc; border-radius: 5px; }
#autoexpert-dev-tools button { margin-right: 5px; }
#chatgpt-timer { color: red; }
#inactivity-alert { display: none; position: fixed; top: 0; left: 0; right: 0; background-color: red; color: white; text-align: center; padding: 10px 0; font-size: 16px; z-index: 1050; animation: pulseAnimation 2s infinite; }
@keyframes pulseAnimation {
0% { opacity: 0.5; }
50% { opacity: 1; }
100% { opacity: 0.5; }
}
`;
GM_addStyle(guiStyles);
// Initialize GUI
const enhancerDiv = document.createElement('div');
enhancerDiv.id = 'autoexpert-dev-tools';
document.body.appendChild(enhancerDiv);
// Inactivity Timer Display
const timerDisplay = document.createElement('span');
timerDisplay.id = 'chatgpt-timer';
timerDisplay.textContent = '10:00';
enhancerDiv.appendChild(timerDisplay);
// Inactivity Alert
const inactivityAlert = document.createElement('div');
inactivityAlert.id = 'inactivity-alert';
inactivityAlert.textContent = 'Inactivity Warning: Your session will expire soon.';
document.body.insertBefore(inactivityAlert, document.body.firstChild);
// Reset timer on interaction
const resetTimer = () => {
timeLeft = 600;
updateTimerDisplay();
inactivityAlert.style.display = 'none';
clearTimeout(preTimeoutStashTrigger);
setupPreTimeoutStash();
};
const setupPreTimeoutStash = () => {
preTimeoutStashTrigger = setTimeout(() => {
executeStashCommand();
}, (timeLeft - 10) * 1000);
};
const executeStashCommand = () => {
// Function to execute the /stash command
};
const updateTimerDisplay = () => {
// Update timer display function
};
const countdown = () => {
if (timeLeft > 0) {
timeLeft--;
updateTimerDisplay();
}
};
setInterval(countdown, 1000);
setupPreTimeoutStash();
document.addEventListener('click', function(e) {
if (e.target.matches('.send-button:not(.disabled), .regenerate-button, .stop-button')) {
resetTimer();
}
});
document.addEventListener('keydown', function(e) {
if (e.key === 'Enter' && !e.shiftKey && e.target.matches('textarea, input[type="text"]')) {
e.preventDefault(); // Prevent default Enter action if not intending to send/submit
resetTimer();
}
});
})();
// ==UserScript==
// @name AutoExpert Dev Tools Enhanced with Visual Timer Alert
// @namespace https://gh.zod.tf/
// @version 1.0
// @description Enhance ChatGPT AutoExpert Dev instance with GUI features including a visual inactivity timer alert.
// @author AutoExpert & zudsniper
// @match https://chat.openai.com/g/g-pTF23RJ6f-autoexpert-dev*
// @grant GM_addStyle
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_deleteValue
// @require FileSaver.js
// ==/UserScript==
(function() {
'use strict';
// GUI Styling
const guiStyles = `
#autoexpert-dev-tools { position: fixed; top: 10px; right: 10px; z-index: 1000; padding: 10px; background-color: #f9f9f9; border: 1px solid #ccc; border-radius: 5px; }
#autoexpert-dev-tools button { margin-right: 5px; }
#chatgpt-timer { color: red; }
#inactivity-alert { display: none; position: fixed; top: 0; left: 0; right: 0; background-color: red; color: white; text-align: center; padding: 10px 0; font-size: 16px; z-index: 1050; animation: pulseAnimation 2s infinite; }
@keyframes pulseAnimation {
0% { opacity: 0.5; }
50% { opacity: 1; }
100% { opacity: 0.5; }
}
`;
GM_addStyle(guiStyles);
// Initialize GUI
const enhancerDiv = document.createElement('div');
enhancerDiv.id = 'autoexpert-dev-tools';
document.body.appendChild(enhancerDiv);
// Inactivity Timer Display
const timerDisplay = document.createElement('span');
timerDisplay.id = 'chatgpt-timer';
timerDisplay.textContent = '10:00';
enhancerDiv.appendChild(timerDisplay);
// Inactivity Alert
const inactivityAlert = document.createElement('div');
inactivityAlert.id = 'inactivity-alert';
inactivityAlert.textContent = 'Inactivity Warning: Your session will expire soon.';
document.body.insertBefore(inactivityAlert, document.body.firstChild);
let timeLeft = 600; // 10 minutes
// Reset timer on interaction
const resetTimer = () => {
timeLeft = 600;
updateTimerDisplay();
inactivityAlert.style.display = 'none';
};
// Update timer display
const updateTimerDisplay = () => {
const minutes = Math.floor(timeLeft / 60);
const seconds = timeLeft % 60;
timerDisplay.textContent = `${minutes}:${seconds.toString().padStart(2, '0')}`;
if (timeLeft <= 120 && inactivityAlert.style.display === 'none') {
inactivityAlert.style.display = 'block';
let pulseSpeed = 2 - ((120 - timeLeft) / 120);
inactivityAlert.style.animationDuration = `${pulseSpeed}s`;
}
};
// Countdown function
const countdown = () => {
if (timeLeft > 0) {
timeLeft--;
updateTimerDisplay();
}
};
// Start the timer
setInterval(countdown, 1000);
// Reset Timer on Page Interactions
document.addEventListener('click', resetTimer);
document.addEventListener('keydown', resetTimer);
})();
@zudsniper
Copy link
Author

https://gist.github.com/zudsniper/6d900b2422ce83b03d852685836c2b08#file-autoexpert-dev-tools-user-js-L102

really this should happen like 15-20 seconds before the timeout timer, but the timeout timer is also an estimate so

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment