chatgpt logout-default prompt

Automatically clicks the 'Stay logged out' button and focuses on text input with default prompt

  1. // ==UserScript==
  2. // @name chatgpt logout-default prompt
  3. // @namespace http://rant.li/boson
  4. // @version 1.5
  5. // @description Automatically clicks the 'Stay logged out' button and focuses on text input with default prompt
  6. // @author Boson
  7. // @match *://chat.openai.com/*
  8. // @match *://chatgpt.com/*
  9. // @grant none
  10. // @license GNU AGPLv3
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. let scriptExecuted = false;
  16. function clickStayLoggedOut(retryCount = 0) {
  17. const element = document.querySelector('.text-token-text-secondary.underline');
  18. if (element) {
  19. element.click();
  20. console.log('Clicked "Stay logged out" button');
  21. setTimeout(focusOnTextInput, 1000);
  22. } else {
  23. console.log('Element not found, retrying...');
  24. if (retryCount < 3) {
  25. setTimeout(clickStayLoggedOut, 1000, retryCount + 1);
  26. } else {
  27. console.log('Failed to find stay logged out element after 5 retries');
  28. }
  29. }
  30. }
  31.  
  32. function focusOnTextInput(retryCount = 0) {
  33. const inputSelector = 'div#prompt-textarea';
  34. const textAreaElement = document.querySelector(inputSelector);
  35. if (textAreaElement) {
  36. if (!textAreaElement.hasAttribute('disabled')) {
  37. if (textAreaElement.offsetWidth > 0 && textAreaElement.offsetHeight > 0) {
  38. textAreaElement.focus();
  39. textAreaElement.textContent = '<instructions> Be technical, precise, efficient, innovative, and concise with graduate-level vocabulary. </instructions> <knowledge>You emulate the most proficient people in the domain relevant to the upcoming questions and are up-to-date with the latest information, technologies and best practices. </knowledge> <question> '; // Replace with your desired query
  40. placeCursorAtEnd(textAreaElement);
  41.  
  42. } else {
  43. console.log('Text input element is not visible');
  44. }
  45. } else {
  46. console.log('Text input element is disabled');
  47. }
  48. } else {
  49. console.log('Text input element not found, retrying...');
  50. if (retryCount < 3) {
  51. setTimeout(focusOnTextInput, 1000, retryCount + 1);
  52. } else {
  53. console.log('Failed to find text input element after 5 retries');
  54. }
  55. }
  56. }
  57.  
  58. function placeCursorAtEnd(element) {
  59. const range = document.createRange();
  60. const selection = window.getSelection();
  61. range.selectNodeContents(element);
  62. range.collapse(false);
  63. selection.removeAllRanges();
  64. selection.addRange(range);
  65. }
  66.  
  67. window.addEventListener('load', function() {
  68. if (!scriptExecuted) {
  69. console.log('Page loaded, attempting to click "Stay logged out"');
  70. clickStayLoggedOut();
  71. scriptExecuted = true;
  72. }
  73. });
  74. })();