From a8bc8d75c54634e023d2be9a1bf7aaf14a01505b Mon Sep 17 00:00:00 2001 From: "Liedke, Daniel" Date: Thu, 23 Mar 2023 08:54:36 -0300 Subject: [PATCH 1/9] Fix Plus users issue when credits header is not showing --- init.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/init.js b/init.js index 85aec85..e2cddb6 100644 --- a/init.js +++ b/init.js @@ -65,7 +65,9 @@ if (textCenterElement == null) { textCenterElement = document.querySelector('.text-center.text-xs'); } - textCenterElement.insertAdjacentHTML('beforeend', '  ✨ Enhanced by CopyGPT') + if (textCenterElement !== null) { + textCenterElement.insertAdjacentHTML('beforeend', '  ✨ Enhanced by CopyGPT'); + } } const chatContainer = document.querySelector('.flex .flex-col .items-center'); From 08a0e29307c4a0623fac9514d3e11f72d5056e1b Mon Sep 17 00:00:00 2001 From: "Liedke, Daniel" Date: Thu, 23 Mar 2023 12:02:48 -0300 Subject: [PATCH 2/9] Configurable settings for copying user prompt message --- init.js | 60 +++++++++++++----- initOriginal.js | 161 +++++++++++++++++++++++++++++++++++++++++++++++ init_Novo.js | 163 ++++++++++++++++++++++++++++++++++++++++++++++++ manifest.json | 6 +- options.html | 12 ++++ settings.js | 30 +++++++++ 6 files changed, 416 insertions(+), 16 deletions(-) create mode 100644 initOriginal.js create mode 100644 init_Novo.js create mode 100644 options.html create mode 100644 settings.js diff --git a/init.js b/init.js index e2cddb6..be513d6 100644 --- a/init.js +++ b/init.js @@ -14,8 +14,9 @@ `) const CHAT_TEXT_SELECTOR = '.markdown'; + const CHAT_TEXT_SELECTOR_ALL = '.markdown,.min-h-\\[20px\\]'; const CLIPBOARD_CLASS_NAME = 'copy-to-clipboard'; - + var copyUserPromptToClipboard = false; const showSnackbar = (message, position) => { const snack = document.createElement('div'); @@ -78,26 +79,55 @@ //check if it is a plus user var plusUser = (chatbubbles.length % 2 === 0) ? false : true; + + //check if copyUserPromptToClipboard is enabled + chrome.storage.sync.get('copyUserPromptToClipboard', function(settings) { + if (settings.copyUserPromptToClipboard) { + copyUserPromptToClipboard = true; + } + }); chatbubbles.forEach((chatbox, i) => { //console.log('chatbox', chatbox); //first chat box needs to be from user, hence all the even chat bubbles are from bot //plus users will have the first row as model selection - if ((i > 0 && (i % 2 === 0) && plusUser) || - ((i + 1) % 2 === 0 && !plusUser)) { - //it is a chat box from bot - const addAfter = chatbox.querySelector(CHAT_TEXT_SELECTOR); - + if ((i > 0 && (i % 2 === 0) && plusUser && !copyUserPromptToClipboard) || + ((i + 1) % 2 === 0 && !plusUser && !copyUserPromptToClipboard) || + (copyUserPromptToClipboard && ((i > 0 && plusUser) || !plusUser))) { + + var addAfter; + var text; + + //Check if showing copy to clipboard for user prompts + if (copyUserPromptToClipboard) { + + //it is a chat box from bot + addAfter = chatbox.querySelector(CHAT_TEXT_SELECTOR); + + if (addAfter===null) { + + //chatbox from user + var addAfterAll = chatbox.querySelectorAll(CHAT_TEXT_SELECTOR_ALL); + if (addAfterAll!=null && addAfterAll.length > 0) { + addAfter = addAfterAll[0]; + } + } + + } else { + //it is a chat box from bot + addAfter = chatbox.querySelector(CHAT_TEXT_SELECTOR); + } + if (chatbox.querySelector(`.${CLIPBOARD_CLASS_NAME}`) === null) { - - //TODO: to check if ChatGPT is done typing check .result-streaming class exists in chatbox - - addAfter.insertAdjacentHTML('afterend', `
-

Copy to Clipboard

clipboard emoji -
`); - chatbox.querySelector(`.${CLIPBOARD_CLASS_NAME}`).addEventListener('click', function () { - - const text = chatbox.querySelector(CHAT_TEXT_SELECTOR).innerText; + + //TODO: to check if ChatGPT is done typing check .result-streaming class exists in chatbox + + addAfter.insertAdjacentHTML('afterend', `
+

Copy to Clipboard

clipboard emoji +
`); + chatbox.querySelector(`.${CLIPBOARD_CLASS_NAME}`).addEventListener('click', function () { + + text = addAfter.innerText; copyToClipboard(text); }); diff --git a/initOriginal.js b/initOriginal.js new file mode 100644 index 0000000..e2cddb6 --- /dev/null +++ b/initOriginal.js @@ -0,0 +1,161 @@ +(async function () { + console.log('%cCopyGPT (Copy For ChatGPT Extension) Loaded', 'color: green; font-size: 30px'); + const currentYear = new Date().getFullYear() + console.log(` + - Copy Button: Enabled ✅ + - CMD+K Hotkey: Enabled ✅ + - Up Arrow Key: Enabled ✅ + - ✨ AI plagiarism checker: Enabled ✅ + + Copyright (c) ${currentYear} Sethu Senthil + Version: 0.3.7 + https://copygpt.sethusenthil.com + https://sethusenthil.com + `) + + const CHAT_TEXT_SELECTOR = '.markdown'; + const CLIPBOARD_CLASS_NAME = 'copy-to-clipboard'; + + + const showSnackbar = (message, position) => { + const snack = document.createElement('div'); + snack.classList.add('snackbar'); + + if (position) { + //default position is bottom + snack.classList.add(position); + } else { + snack.classList.add('bottom'); + } + + snack.innerText = message; + document.body.appendChild(snack); + snack.classList.add('show'); + setTimeout(function () { + snack.className = snack.className.replace("show", ""); + snack.remove(); + }, 3000); + }; + + chrome.runtime.onMessage.addListener(function (response, sender, sendResponse) { + // console.log('response', response); + + if (response.message.documents[0].average_generated_prob >= 0.5) { + showSnackbar('This text was flagged as AI generated by plagiarism detectors, make some changes before submitting! 🚨', 'top'); + } else { + showSnackbar('Your text was not flagged by AI detectors! ✅', 'top'); + } + }); + + const copyToClipboard = (str) => { + chrome.runtime.sendMessage({ message: str }); + + navigator.clipboard.writeText(str).then(function () { + //console.log('Async: Copying to clipboard was successful!'); + }, function (err) { + console.error('Async: Could not copy text: ', err); + }); + showSnackbar('Copied to clipboard 📋'); + }; + + + const intervalId = window.setInterval(async function () { + if (!document.querySelector('#copygpt-credits')) { + var textCenterElement = document.querySelector('.text-center'); + if (textCenterElement == null) { + textCenterElement = document.querySelector('.text-center.text-xs'); + } + if (textCenterElement !== null) { + textCenterElement.insertAdjacentHTML('beforeend', '  ✨ Enhanced by CopyGPT'); + } + } + + const chatContainer = document.querySelector('.flex .flex-col .items-center'); + + //console.log('probing for new chat bubbles'); + const chatbubbles = chatContainer.querySelectorAll('main.w-full .border-b'); + //console.log('chatbubbles', chatbubbles); + + //check if it is a plus user + var plusUser = (chatbubbles.length % 2 === 0) ? false : true; + + chatbubbles.forEach((chatbox, i) => { + //console.log('chatbox', chatbox); + //first chat box needs to be from user, hence all the even chat bubbles are from bot + //plus users will have the first row as model selection + if ((i > 0 && (i % 2 === 0) && plusUser) || + ((i + 1) % 2 === 0 && !plusUser)) { + //it is a chat box from bot + const addAfter = chatbox.querySelector(CHAT_TEXT_SELECTOR); + + if (chatbox.querySelector(`.${CLIPBOARD_CLASS_NAME}`) === null) { + + //TODO: to check if ChatGPT is done typing check .result-streaming class exists in chatbox + + addAfter.insertAdjacentHTML('afterend', `
+

Copy to Clipboard

clipboard emoji +
`); + chatbox.querySelector(`.${CLIPBOARD_CLASS_NAME}`).addEventListener('click', function () { + + const text = chatbox.querySelector(CHAT_TEXT_SELECTOR).innerText; + copyToClipboard(text); + + }); + } + } + }); + + if (chatContainer.getAttribute('listener-injected') !== 'true') { + + //console.log('setting event listener cause its not already there') + document.addEventListener('keydown', function (event) { + const chatContainer = document.querySelector('.flex .flex-col .items-center'); + + // check for CTRL+K on Windows or CMD+K on Mac + if ((event.ctrlKey || event.metaKey) && event.keyCode === 75) { + //console.log('Copy Shortcut Pressed'); + + const chatbubbles = chatContainer.querySelectorAll('main.w-full .border-b'); + + //check if it is a plus user + var plusUser = (chatbubbles.length % 2 === 0) ? false : true; + + if (((chatbubbles.length % 2 === 0) && !plusUser) || + ((chatbubbles.length % 2 === 1) && plusUser)) { + //if last chat is from bot + const lastChatBubble = chatbubbles[chatbubbles.length - 1]; + const text = lastChatBubble.querySelector(CHAT_TEXT_SELECTOR).innerText + copyToClipboard(text); + } + + } + chatContainer.setAttribute('listener-injected', 'true'); + }); + + const textarea = document.querySelector('textarea'); + + textarea.addEventListener('keydown', function (event) { + if (event.key === 'ArrowUp') { + if (chatbubbles.length > 0) { + let lastSetIndex = chatContainer.getAttribute('last-set-index') ?? 0; + //console.log('lastSetIndex', lastSetIndex); + + if (lastSetIndex >= chatbubbles.length) { + lastSetIndex = 0; + } + + lastSetIndex++; + + const lastChatBubble = chatbubbles[chatbubbles.length - lastSetIndex]; + const text = lastChatBubble.innerText + + textarea.value = text; + chatContainer.setAttribute('last-set-index', lastSetIndex); + } + } + }); + } + }, 1000); + +})(); + diff --git a/init_Novo.js b/init_Novo.js new file mode 100644 index 0000000..230659d --- /dev/null +++ b/init_Novo.js @@ -0,0 +1,163 @@ +(async function () { + console.log('%cCopyGPT (Copy For ChatGPT Extension) Loaded', 'color: green; font-size: 30px'); + const currentYear = new Date().getFullYear() + console.log(` + - Copy Button: Enabled ✅ + - CMD+K Hotkey: Enabled ✅ + - Up Arrow Key: Enabled ✅ + - ✨ AI plagiarism checker: Enabled ✅ + + Copyright (c) ${currentYear} Sethu Senthil + Version: 0.3.7 + https://copygpt.sethusenthil.com + https://sethusenthil.com + `) + + const CHAT_TEXT_SELECTOR = '.markdown,.min-h-\\[20px\\]'; + const CLIPBOARD_CLASS_NAME = 'copy-to-clipboard'; + + + const showSnackbar = (message, position) => { + const snack = document.createElement('div'); + snack.classList.add('snackbar'); + + if (position) { + //default position is bottom + snack.classList.add(position); + } else { + snack.classList.add('bottom'); + } + + snack.innerText = message; + document.body.appendChild(snack); + snack.classList.add('show'); + setTimeout(function () { + snack.className = snack.className.replace("show", ""); + snack.remove(); + }, 3000); + }; + + chrome.runtime.onMessage.addListener(function (response, sender, sendResponse) { + // console.log('response', response); + + if (response.message.documents[0].average_generated_prob >= 0.5) { + showSnackbar('This text was flagged as AI generated by plagiarism detectors, make some changes before submitting! 🚨', 'top'); + } else { + showSnackbar('Your text was not flagged by AI detectors! ✅', 'top'); + } + }); + + const copyToClipboard = (str) => { + chrome.runtime.sendMessage({ message: str }); + + navigator.clipboard.writeText(str).then(function () { + //console.log('Async: Copying to clipboard was successful!'); + }, function (err) { + console.error('Async: Could not copy text: ', err); + }); + showSnackbar('Copied to clipboard 📋'); + }; + + + const intervalId = window.setInterval(async function () { + if (!document.querySelector('#copygpt-credits')) { + var textCenterElement = document.querySelector('.text-center'); + if (textCenterElement == null) { + textCenterElement = document.querySelector('.text-center.text-xs'); + } + if (textCenterElement != null) { + textCenterElement.insertAdjacentHTML('beforeend', '  ✨ Enhanced by CopyGPT') + } + } + + const chatContainer = document.querySelector('.flex .flex-col .items-center'); + + //console.log('probing for new chat bubbles'); + const chatbubbles = chatContainer.querySelectorAll('main.w-full .border-b'); + //console.log('chatbubbles', chatbubbles); + + //check if it is a plus user + var plusUser = (chatbubbles.length % 2 === 0) ? false : true; + + chatbubbles.forEach((chatbox, i) => { + //console.log('chatbox', chatbox); + //first chat box needs to be from user, hence all the even chat bubbles are from bot + //plus users will have the first row as model selection +// if ((i > 0 && (i % 2 === 0) && plusUser) || + // ((i + 1) % 2 === 0 && !plusUser)) + if (i>0) + { + //it is a chat box from bot + const addAfter = chatbox.querySelectorAll(CHAT_TEXT_SELECTOR); + + if (chatbox.querySelector(`.${CLIPBOARD_CLASS_NAME}`) === null && addAfter!=null && addAfter.length > 0) { + + //TODO: to check if ChatGPT is done typing check .result-streaming class exists in chatbox + + addAfter[0].insertAdjacentHTML('afterend', `
+

Copy to Clipboard

clipboard emoji +
`); + chatbox.querySelector(`.${CLIPBOARD_CLASS_NAME}`).addEventListener('click', function () { + + const text = addAfter[0].innerText; + copyToClipboard(text); + + }); + } + } + }); + + if (chatContainer.getAttribute('listener-injected') !== 'true') { + + //console.log('setting event listener cause its not already there') + document.addEventListener('keydown', function (event) { + const chatContainer = document.querySelector('.flex .flex-col .items-center'); + + // check for CTRL+K on Windows or CMD+K on Mac + if ((event.ctrlKey || event.metaKey) && event.keyCode === 75) { + //console.log('Copy Shortcut Pressed'); + + const chatbubbles = chatContainer.querySelectorAll('main.w-full .border-b'); + + //check if it is a plus user + var plusUser = (chatbubbles.length % 2 === 0) ? false : true; + + if (((chatbubbles.length % 2 === 0) && !plusUser) || + ((chatbubbles.length % 2 === 1) && plusUser)) { + //if last chat is from bot + const lastChatBubble = chatbubbles[chatbubbles.length - 1]; + const text = lastChatBubble.querySelector(CHAT_TEXT_SELECTOR).innerText + copyToClipboard(text); + } + + } + chatContainer.setAttribute('listener-injected', 'true'); + }); + + const textarea = document.querySelector('textarea'); + + textarea.addEventListener('keydown', function (event) { + if (event.key === 'ArrowUp') { + if (chatbubbles.length > 0) { + let lastSetIndex = chatContainer.getAttribute('last-set-index') ?? 0; + //console.log('lastSetIndex', lastSetIndex); + + if (lastSetIndex >= chatbubbles.length) { + lastSetIndex = 0; + } + + lastSetIndex++; + + const lastChatBubble = chatbubbles[chatbubbles.length - lastSetIndex]; + const text = lastChatBubble.innerText + + textarea.value = text; + chatContainer.setAttribute('last-set-index', lastSetIndex); + } + } + }); + } + }, 1000); + +})(); + diff --git a/manifest.json b/manifest.json index 8b9a504..380d8ac 100644 --- a/manifest.json +++ b/manifest.json @@ -14,13 +14,17 @@ "host_permissions": [ "https://api.gptzero.me/*" ], + "permissions": [ + "storage" + ], "background": { "service_worker": "background.js" }, + "options_page": "options.html", "content_scripts": [ { "js": [ - "init.js" + "init.js","settings.js" ], "css": [ "styles.css" diff --git a/options.html b/options.html new file mode 100644 index 0000000..58c9f63 --- /dev/null +++ b/options.html @@ -0,0 +1,12 @@ + + + + + Copy For ChatGPT Settings + + +

Copy For ChatGPT Settings

+
+ + + diff --git a/settings.js b/settings.js new file mode 100644 index 0000000..94a602b --- /dev/null +++ b/settings.js @@ -0,0 +1,30 @@ +// Define the default settings +const DEFAULT_SETTINGS = { + copyUserPromptToClipboard: true +}; + +// Load the settings from storage +chrome.storage.sync.get(DEFAULT_SETTINGS, function(settings) { + // Apply the settings to the extension + const copyUserPromptCheckbox = document.getElementById("copyUserPromptToClipboard"); + copyUserPromptCheckbox.checked = settings.copyUserPromptToClipboard; +}); + +// Save the settings when they are changed +function saveSettings() { + const settings = { + copyUserPromptToClipboard: document.getElementById("copyUserPromptToClipboard").checked + }; + chrome.storage.sync.set(settings); +} + +// Create the settings UI +const settingsDiv = document.createElement("div"); +settingsDiv.innerHTML = ` + +`; +settingsDiv.addEventListener("change", saveSettings); +document.body.appendChild(settingsDiv); From 349a1401612683d35fc0ec9ff274075254b5efe7 Mon Sep 17 00:00:00 2001 From: "Liedke, Daniel" Date: Thu, 23 Mar 2023 12:03:17 -0300 Subject: [PATCH 3/9] Deleted old files --- initOriginal.js | 161 ----------------------------------------------- init_Novo.js | 163 ------------------------------------------------ 2 files changed, 324 deletions(-) delete mode 100644 initOriginal.js delete mode 100644 init_Novo.js diff --git a/initOriginal.js b/initOriginal.js deleted file mode 100644 index e2cddb6..0000000 --- a/initOriginal.js +++ /dev/null @@ -1,161 +0,0 @@ -(async function () { - console.log('%cCopyGPT (Copy For ChatGPT Extension) Loaded', 'color: green; font-size: 30px'); - const currentYear = new Date().getFullYear() - console.log(` - - Copy Button: Enabled ✅ - - CMD+K Hotkey: Enabled ✅ - - Up Arrow Key: Enabled ✅ - - ✨ AI plagiarism checker: Enabled ✅ - - Copyright (c) ${currentYear} Sethu Senthil - Version: 0.3.7 - https://copygpt.sethusenthil.com - https://sethusenthil.com - `) - - const CHAT_TEXT_SELECTOR = '.markdown'; - const CLIPBOARD_CLASS_NAME = 'copy-to-clipboard'; - - - const showSnackbar = (message, position) => { - const snack = document.createElement('div'); - snack.classList.add('snackbar'); - - if (position) { - //default position is bottom - snack.classList.add(position); - } else { - snack.classList.add('bottom'); - } - - snack.innerText = message; - document.body.appendChild(snack); - snack.classList.add('show'); - setTimeout(function () { - snack.className = snack.className.replace("show", ""); - snack.remove(); - }, 3000); - }; - - chrome.runtime.onMessage.addListener(function (response, sender, sendResponse) { - // console.log('response', response); - - if (response.message.documents[0].average_generated_prob >= 0.5) { - showSnackbar('This text was flagged as AI generated by plagiarism detectors, make some changes before submitting! 🚨', 'top'); - } else { - showSnackbar('Your text was not flagged by AI detectors! ✅', 'top'); - } - }); - - const copyToClipboard = (str) => { - chrome.runtime.sendMessage({ message: str }); - - navigator.clipboard.writeText(str).then(function () { - //console.log('Async: Copying to clipboard was successful!'); - }, function (err) { - console.error('Async: Could not copy text: ', err); - }); - showSnackbar('Copied to clipboard 📋'); - }; - - - const intervalId = window.setInterval(async function () { - if (!document.querySelector('#copygpt-credits')) { - var textCenterElement = document.querySelector('.text-center'); - if (textCenterElement == null) { - textCenterElement = document.querySelector('.text-center.text-xs'); - } - if (textCenterElement !== null) { - textCenterElement.insertAdjacentHTML('beforeend', '  ✨ Enhanced by CopyGPT'); - } - } - - const chatContainer = document.querySelector('.flex .flex-col .items-center'); - - //console.log('probing for new chat bubbles'); - const chatbubbles = chatContainer.querySelectorAll('main.w-full .border-b'); - //console.log('chatbubbles', chatbubbles); - - //check if it is a plus user - var plusUser = (chatbubbles.length % 2 === 0) ? false : true; - - chatbubbles.forEach((chatbox, i) => { - //console.log('chatbox', chatbox); - //first chat box needs to be from user, hence all the even chat bubbles are from bot - //plus users will have the first row as model selection - if ((i > 0 && (i % 2 === 0) && plusUser) || - ((i + 1) % 2 === 0 && !plusUser)) { - //it is a chat box from bot - const addAfter = chatbox.querySelector(CHAT_TEXT_SELECTOR); - - if (chatbox.querySelector(`.${CLIPBOARD_CLASS_NAME}`) === null) { - - //TODO: to check if ChatGPT is done typing check .result-streaming class exists in chatbox - - addAfter.insertAdjacentHTML('afterend', `
-

Copy to Clipboard

clipboard emoji -
`); - chatbox.querySelector(`.${CLIPBOARD_CLASS_NAME}`).addEventListener('click', function () { - - const text = chatbox.querySelector(CHAT_TEXT_SELECTOR).innerText; - copyToClipboard(text); - - }); - } - } - }); - - if (chatContainer.getAttribute('listener-injected') !== 'true') { - - //console.log('setting event listener cause its not already there') - document.addEventListener('keydown', function (event) { - const chatContainer = document.querySelector('.flex .flex-col .items-center'); - - // check for CTRL+K on Windows or CMD+K on Mac - if ((event.ctrlKey || event.metaKey) && event.keyCode === 75) { - //console.log('Copy Shortcut Pressed'); - - const chatbubbles = chatContainer.querySelectorAll('main.w-full .border-b'); - - //check if it is a plus user - var plusUser = (chatbubbles.length % 2 === 0) ? false : true; - - if (((chatbubbles.length % 2 === 0) && !plusUser) || - ((chatbubbles.length % 2 === 1) && plusUser)) { - //if last chat is from bot - const lastChatBubble = chatbubbles[chatbubbles.length - 1]; - const text = lastChatBubble.querySelector(CHAT_TEXT_SELECTOR).innerText - copyToClipboard(text); - } - - } - chatContainer.setAttribute('listener-injected', 'true'); - }); - - const textarea = document.querySelector('textarea'); - - textarea.addEventListener('keydown', function (event) { - if (event.key === 'ArrowUp') { - if (chatbubbles.length > 0) { - let lastSetIndex = chatContainer.getAttribute('last-set-index') ?? 0; - //console.log('lastSetIndex', lastSetIndex); - - if (lastSetIndex >= chatbubbles.length) { - lastSetIndex = 0; - } - - lastSetIndex++; - - const lastChatBubble = chatbubbles[chatbubbles.length - lastSetIndex]; - const text = lastChatBubble.innerText - - textarea.value = text; - chatContainer.setAttribute('last-set-index', lastSetIndex); - } - } - }); - } - }, 1000); - -})(); - diff --git a/init_Novo.js b/init_Novo.js deleted file mode 100644 index 230659d..0000000 --- a/init_Novo.js +++ /dev/null @@ -1,163 +0,0 @@ -(async function () { - console.log('%cCopyGPT (Copy For ChatGPT Extension) Loaded', 'color: green; font-size: 30px'); - const currentYear = new Date().getFullYear() - console.log(` - - Copy Button: Enabled ✅ - - CMD+K Hotkey: Enabled ✅ - - Up Arrow Key: Enabled ✅ - - ✨ AI plagiarism checker: Enabled ✅ - - Copyright (c) ${currentYear} Sethu Senthil - Version: 0.3.7 - https://copygpt.sethusenthil.com - https://sethusenthil.com - `) - - const CHAT_TEXT_SELECTOR = '.markdown,.min-h-\\[20px\\]'; - const CLIPBOARD_CLASS_NAME = 'copy-to-clipboard'; - - - const showSnackbar = (message, position) => { - const snack = document.createElement('div'); - snack.classList.add('snackbar'); - - if (position) { - //default position is bottom - snack.classList.add(position); - } else { - snack.classList.add('bottom'); - } - - snack.innerText = message; - document.body.appendChild(snack); - snack.classList.add('show'); - setTimeout(function () { - snack.className = snack.className.replace("show", ""); - snack.remove(); - }, 3000); - }; - - chrome.runtime.onMessage.addListener(function (response, sender, sendResponse) { - // console.log('response', response); - - if (response.message.documents[0].average_generated_prob >= 0.5) { - showSnackbar('This text was flagged as AI generated by plagiarism detectors, make some changes before submitting! 🚨', 'top'); - } else { - showSnackbar('Your text was not flagged by AI detectors! ✅', 'top'); - } - }); - - const copyToClipboard = (str) => { - chrome.runtime.sendMessage({ message: str }); - - navigator.clipboard.writeText(str).then(function () { - //console.log('Async: Copying to clipboard was successful!'); - }, function (err) { - console.error('Async: Could not copy text: ', err); - }); - showSnackbar('Copied to clipboard 📋'); - }; - - - const intervalId = window.setInterval(async function () { - if (!document.querySelector('#copygpt-credits')) { - var textCenterElement = document.querySelector('.text-center'); - if (textCenterElement == null) { - textCenterElement = document.querySelector('.text-center.text-xs'); - } - if (textCenterElement != null) { - textCenterElement.insertAdjacentHTML('beforeend', '  ✨ Enhanced by CopyGPT') - } - } - - const chatContainer = document.querySelector('.flex .flex-col .items-center'); - - //console.log('probing for new chat bubbles'); - const chatbubbles = chatContainer.querySelectorAll('main.w-full .border-b'); - //console.log('chatbubbles', chatbubbles); - - //check if it is a plus user - var plusUser = (chatbubbles.length % 2 === 0) ? false : true; - - chatbubbles.forEach((chatbox, i) => { - //console.log('chatbox', chatbox); - //first chat box needs to be from user, hence all the even chat bubbles are from bot - //plus users will have the first row as model selection -// if ((i > 0 && (i % 2 === 0) && plusUser) || - // ((i + 1) % 2 === 0 && !plusUser)) - if (i>0) - { - //it is a chat box from bot - const addAfter = chatbox.querySelectorAll(CHAT_TEXT_SELECTOR); - - if (chatbox.querySelector(`.${CLIPBOARD_CLASS_NAME}`) === null && addAfter!=null && addAfter.length > 0) { - - //TODO: to check if ChatGPT is done typing check .result-streaming class exists in chatbox - - addAfter[0].insertAdjacentHTML('afterend', `
-

Copy to Clipboard

clipboard emoji -
`); - chatbox.querySelector(`.${CLIPBOARD_CLASS_NAME}`).addEventListener('click', function () { - - const text = addAfter[0].innerText; - copyToClipboard(text); - - }); - } - } - }); - - if (chatContainer.getAttribute('listener-injected') !== 'true') { - - //console.log('setting event listener cause its not already there') - document.addEventListener('keydown', function (event) { - const chatContainer = document.querySelector('.flex .flex-col .items-center'); - - // check for CTRL+K on Windows or CMD+K on Mac - if ((event.ctrlKey || event.metaKey) && event.keyCode === 75) { - //console.log('Copy Shortcut Pressed'); - - const chatbubbles = chatContainer.querySelectorAll('main.w-full .border-b'); - - //check if it is a plus user - var plusUser = (chatbubbles.length % 2 === 0) ? false : true; - - if (((chatbubbles.length % 2 === 0) && !plusUser) || - ((chatbubbles.length % 2 === 1) && plusUser)) { - //if last chat is from bot - const lastChatBubble = chatbubbles[chatbubbles.length - 1]; - const text = lastChatBubble.querySelector(CHAT_TEXT_SELECTOR).innerText - copyToClipboard(text); - } - - } - chatContainer.setAttribute('listener-injected', 'true'); - }); - - const textarea = document.querySelector('textarea'); - - textarea.addEventListener('keydown', function (event) { - if (event.key === 'ArrowUp') { - if (chatbubbles.length > 0) { - let lastSetIndex = chatContainer.getAttribute('last-set-index') ?? 0; - //console.log('lastSetIndex', lastSetIndex); - - if (lastSetIndex >= chatbubbles.length) { - lastSetIndex = 0; - } - - lastSetIndex++; - - const lastChatBubble = chatbubbles[chatbubbles.length - lastSetIndex]; - const text = lastChatBubble.innerText - - textarea.value = text; - chatContainer.setAttribute('last-set-index', lastSetIndex); - } - } - }); - } - }, 1000); - -})(); - From 155411fa77871658e29d191599ff566264bacd44 Mon Sep 17 00:00:00 2001 From: "Liedke, Daniel" Date: Tue, 28 Mar 2023 15:49:02 -0300 Subject: [PATCH 4/9] CTRL+UP or CMD+UP to navigate through user previous prompts --- init.js | 62 +++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/init.js b/init.js index be513d6..f97d304 100644 --- a/init.js +++ b/init.js @@ -164,27 +164,51 @@ const textarea = document.querySelector('textarea'); - textarea.addEventListener('keydown', function (event) { - if (event.key === 'ArrowUp') { - if (chatbubbles.length > 0) { - let lastSetIndex = chatContainer.getAttribute('last-set-index') ?? 0; - //console.log('lastSetIndex', lastSetIndex); + if (textarea.getAttribute('listener-injected') !== 'true') { + textarea.setAttribute('listener-injected', 'true'); + textarea.addEventListener('keydown', function (event) { - if (lastSetIndex >= chatbubbles.length) { - lastSetIndex = 0; - } - - lastSetIndex++; - - const lastChatBubble = chatbubbles[chatbubbles.length - lastSetIndex]; - const text = lastChatBubble.innerText + // CTRL+UP or CMD+UP to navigate through user previous prompts + if ((event.ctrlKey || event.metaKey) && (event.key === 'ArrowUp')) { + + const chatContainer = document.querySelector('.flex .flex-col .items-center'); + const chatbubbles = chatContainer.querySelectorAll('main.w-full .border-b'); + + if (chatbubbles.length > 0) { + let lastSetIndex = chatContainer.getAttribute('last-set-index') ?? chatbubbles.length; + + if (event.key === 'ArrowUp') { + lastSetIndex-=2; + + //check if it is a plus user + var plusUser = (chatbubbles.length % 2 === 0) ? false : true; + var firstIndex = plusUser ? 1 : 0 + + if (lastSetIndex < firstIndex) { + lastSetIndex = chatbubbles.length-2; + } + } + + const lastChatBubble = chatbubbles[lastSetIndex]; + var text = lastChatBubble.innerText - textarea.value = text; - chatContainer.setAttribute('last-set-index', lastSetIndex); - } - } - }); - } + text = text.replace('\n\nCopy to Clipboard',''); + textarea.value = text; + + // Expand the textarea if prompt is multiline otherwise keeps default size + if (text.includes('\n')) { + textarea.setAttribute('style','max-height: 200px; height: 264px;'); + } else { + textarea.setAttribute('style', 'max-height: 200px; height: 24px; overflow-y: hidden;'); + } + + chatContainer.setAttribute('last-set-index', lastSetIndex); + } + } + }); + } + } + }, 1000); })(); From f61364bb97e868bbabcede8898513b9a186fd1ea Mon Sep 17 00:00:00 2001 From: "Liedke, Daniel" Date: Thu, 6 Apr 2023 18:03:29 -0300 Subject: [PATCH 5/9] Fixed extension for ChatGPT Mar 23 Version --- init.js | 129 ++++++++++++++++---------------------------------- manifest.json | 2 +- settings.js | 2 +- 3 files changed, 43 insertions(+), 90 deletions(-) diff --git a/init.js b/init.js index f97d304..1c37b94 100644 --- a/init.js +++ b/init.js @@ -7,15 +7,13 @@ - Up Arrow Key: Enabled ✅ - ✨ AI plagiarism checker: Enabled ✅ - Copyright (c) ${currentYear} Sethu Senthil - Version: 0.3.7 + Copyright (c) ${currentYear} Sethu Senthil / Daniel Liedke + Version: 0.3.8 https://copygpt.sethusenthil.com https://sethusenthil.com `) const CHAT_TEXT_SELECTOR = '.markdown'; - const CHAT_TEXT_SELECTOR_ALL = '.markdown,.min-h-\\[20px\\]'; - const CLIPBOARD_CLASS_NAME = 'copy-to-clipboard'; var copyUserPromptToClipboard = false; const showSnackbar = (message, position) => { @@ -39,8 +37,7 @@ }; chrome.runtime.onMessage.addListener(function (response, sender, sendResponse) { - // console.log('response', response); - + if (response.message.documents[0].average_generated_prob >= 0.5) { showSnackbar('This text was flagged as AI generated by plagiarism detectors, make some changes before submitting! 🚨', 'top'); } else { @@ -52,7 +49,7 @@ chrome.runtime.sendMessage({ message: str }); navigator.clipboard.writeText(str).then(function () { - //console.log('Async: Copying to clipboard was successful!'); + }, function (err) { console.error('Async: Could not copy text: ', err); }); @@ -62,96 +59,56 @@ const intervalId = window.setInterval(async function () { if (!document.querySelector('#copygpt-credits')) { - var textCenterElement = document.querySelector('.text-center'); - if (textCenterElement == null) { - textCenterElement = document.querySelector('.text-center.text-xs'); + var textCenterElement = document.querySelector('.text-center'); + if (textCenterElement == null) { + textCenterElement = document.querySelector('.text-center.text-xs'); + } + if (textCenterElement !== null) { + textCenterElement.insertAdjacentHTML('beforeend', '  ✨ Enhanced by CopyGPT'); } - if (textCenterElement !== null) { - textCenterElement.insertAdjacentHTML('beforeend', '  ✨ Enhanced by CopyGPT'); - } } - const chatContainer = document.querySelector('.flex .flex-col .items-center'); - - //console.log('probing for new chat bubbles'); - const chatbubbles = chatContainer.querySelectorAll('main.w-full .border-b'); - //console.log('chatbubbles', chatbubbles); - - //check if it is a plus user - var plusUser = (chatbubbles.length % 2 === 0) ? false : true; - - //check if copyUserPromptToClipboard is enabled - chrome.storage.sync.get('copyUserPromptToClipboard', function(settings) { - if (settings.copyUserPromptToClipboard) { - copyUserPromptToClipboard = true; - } - }); + const chatContainer = document.querySelector('div.flex.flex-col.items-center.text-sm.dark\\:bg-gray-800'); + const chatbubbles = chatContainer.querySelectorAll('.flex .flex-grow .flex-col'); + + //check if copyUserPromptToClipboard is enabled + chrome.storage.sync.get('copyUserPromptToClipboard', function(settings) { + if (settings.copyUserPromptToClipboard) { + copyUserPromptToClipboard = true; + } + }); chatbubbles.forEach((chatbox, i) => { - //console.log('chatbox', chatbox); - //first chat box needs to be from user, hence all the even chat bubbles are from bot - //plus users will have the first row as model selection - if ((i > 0 && (i % 2 === 0) && plusUser && !copyUserPromptToClipboard) || - ((i + 1) % 2 === 0 && !plusUser && !copyUserPromptToClipboard) || - (copyUserPromptToClipboard && ((i > 0 && plusUser) || !plusUser))) { - - var addAfter; - var text; - - //Check if showing copy to clipboard for user prompts - if (copyUserPromptToClipboard) { - - //it is a chat box from bot - addAfter = chatbox.querySelector(CHAT_TEXT_SELECTOR); - - if (addAfter===null) { - - //chatbox from user - var addAfterAll = chatbox.querySelectorAll(CHAT_TEXT_SELECTOR_ALL); - if (addAfterAll!=null && addAfterAll.length > 0) { - addAfter = addAfterAll[0]; - } - } - - } else { - //it is a chat box from bot - addAfter = chatbox.querySelector(CHAT_TEXT_SELECTOR); - } - - if (chatbox.querySelector(`.${CLIPBOARD_CLASS_NAME}`) === null) { - - //TODO: to check if ChatGPT is done typing check .result-streaming class exists in chatbox - - addAfter.insertAdjacentHTML('afterend', `
-

Copy to Clipboard

clipboard emoji -
`); - chatbox.querySelector(`.${CLIPBOARD_CLASS_NAME}`).addEventListener('click', function () { - - text = addAfter.innerText; - copyToClipboard(text); - - }); - } - } + { + var text; + + if (chatbox.parentElement.querySelector('.copy-to-clipboard') === null && (!(!copyUserPromptToClipboard && i % 2 === 0))) { + + chatbox.insertAdjacentHTML('afterend', `
+

Copy to Clipboard

clipboard emoji +
`); + chatbox.parentElement.querySelector('.copy-to-clipboard').addEventListener('click', function () { + + text = chatbox.innerText; + copyToClipboard(text); + + }); + } + } }); if (chatContainer.getAttribute('listener-injected') !== 'true') { - //console.log('setting event listener cause its not already there') document.addEventListener('keydown', function (event) { - const chatContainer = document.querySelector('.flex .flex-col .items-center'); + const chatContainer = document.querySelector('div.flex.flex-col.items-center.text-sm.dark\\:bg-gray-800'); // check for CTRL+K on Windows or CMD+K on Mac if ((event.ctrlKey || event.metaKey) && event.keyCode === 75) { - //console.log('Copy Shortcut Pressed'); - const chatbubbles = chatContainer.querySelectorAll('main.w-full .border-b'); + const chatbubbles = chatContainer.querySelectorAll('.flex .flex-grow .flex-col'); - //check if it is a plus user - var plusUser = (chatbubbles.length % 2 === 0) ? false : true; + if (chatbubbles.length % 2 === 0) { - if (((chatbubbles.length % 2 === 0) && !plusUser) || - ((chatbubbles.length % 2 === 1) && plusUser)) { //if last chat is from bot const lastChatBubble = chatbubbles[chatbubbles.length - 1]; const text = lastChatBubble.querySelector(CHAT_TEXT_SELECTOR).innerText @@ -171,20 +128,16 @@ // CTRL+UP or CMD+UP to navigate through user previous prompts if ((event.ctrlKey || event.metaKey) && (event.key === 'ArrowUp')) { - const chatContainer = document.querySelector('.flex .flex-col .items-center'); - const chatbubbles = chatContainer.querySelectorAll('main.w-full .border-b'); + const chatContainer = document.querySelector('div.flex.flex-col.items-center.text-sm.dark\\:bg-gray-800'); + const chatbubbles = chatContainer.querySelectorAll('.flex .flex-grow .flex-col'); if (chatbubbles.length > 0) { let lastSetIndex = chatContainer.getAttribute('last-set-index') ?? chatbubbles.length; if (event.key === 'ArrowUp') { lastSetIndex-=2; - - //check if it is a plus user - var plusUser = (chatbubbles.length % 2 === 0) ? false : true; - var firstIndex = plusUser ? 1 : 0 - if (lastSetIndex < firstIndex) { + if (lastSetIndex < 0) { lastSetIndex = chatbubbles.length-2; } } diff --git a/manifest.json b/manifest.json index 380d8ac..3217883 100644 --- a/manifest.json +++ b/manifest.json @@ -10,7 +10,7 @@ "128": "media/128.png" }, "description": "This extension allows you to copy chat GPT responses with a click of a button or CMD+K and runs it through plagiarism detectors", - "version": "0.3.7", + "version": "0.3.8", "host_permissions": [ "https://api.gptzero.me/*" ], diff --git a/settings.js b/settings.js index 94a602b..7133563 100644 --- a/settings.js +++ b/settings.js @@ -23,7 +23,7 @@ const settingsDiv = document.createElement("div"); settingsDiv.innerHTML = ` `; settingsDiv.addEventListener("change", saveSettings); From 87e2f71d66b29952002a2d7e42f5693bc7c7a2cc Mon Sep 17 00:00:00 2001 From: dliedke Date: Sat, 27 May 2023 10:32:57 -0300 Subject: [PATCH 6/9] Fix integration issues for ChatGPT May 24 Version and updated version to 0.4.0 --- init.js | 99 ++++++++++++++++++++++++++++----------------------- manifest.json | 2 +- 2 files changed, 56 insertions(+), 45 deletions(-) diff --git a/init.js b/init.js index 1d44aaf..b6d1186 100644 --- a/init.js +++ b/init.js @@ -8,7 +8,7 @@ - ✨ AI plagiarism checker: Enabled ✅ Copyright (c) ${currentYear} Sethu Senthil / Daniel Liedke - Version: 0.3.8 + Version: 0.4.0 https://copygpt.sethusenthil.com https://sethusenthil.com `) @@ -68,7 +68,11 @@ } } - const chatContainer = document.querySelector('div.flex.flex-col.items-center.text-sm.dark\\:bg-gray-800'); + const chatContainer = document.querySelector('.h-full.dark\\:bg-gray-800'); + if (chatContainer===null) { + return; + } + const chatbubbles = chatContainer.querySelectorAll('.flex .flex-grow .flex-col'); //check if copyUserPromptToClipboard is enabled @@ -100,7 +104,10 @@ if (chatContainer.getAttribute('listener-injected') !== 'true') { document.addEventListener('keydown', function (event) { - const chatContainer = document.querySelector('div.flex.flex-col.items-center.text-sm.dark\\:bg-gray-800'); + const chatContainer = document.querySelector('.h-full.dark\\:bg-gray-800'); + if (chatContainer===null) { + return; + } // check for CTRL+K on Windows or CMD+K on Mac if ((event.ctrlKey || event.metaKey) && event.keyCode === 75) { @@ -121,47 +128,51 @@ const textarea = document.querySelector('textarea'); - if (textarea.getAttribute('listener-injected') !== 'true') { - textarea.setAttribute('listener-injected', 'true'); - textarea.addEventListener('keydown', function (event) { - - // CTRL+UP or CMD+UP to navigate through user previous prompts - if ((event.ctrlKey || event.metaKey) && (event.key === 'ArrowUp')) { - - const chatContainer = document.querySelector('div.flex.flex-col.items-center.text-sm.dark\\:bg-gray-800'); - const chatbubbles = chatContainer.querySelectorAll('.flex .flex-grow .flex-col'); - - if (chatbubbles.length > 0) { - let lastSetIndex = chatContainer.getAttribute('last-set-index') ?? chatbubbles.length; - - if (event.key === 'ArrowUp') { - lastSetIndex-=2; - - if (lastSetIndex < 0) { - lastSetIndex = chatbubbles.length-2; - } - } - - const lastChatBubble = chatbubbles[lastSetIndex]; - var text = lastChatBubble.innerText - - text = text.replace('\n\nCopy to Clipboard',''); - textarea.value = text; - - // Expand the textarea if prompt is multiline otherwise keeps default size - if (text.includes('\n')) { - textarea.setAttribute('style','max-height: 200px; height: 264px;'); - } else { - textarea.setAttribute('style', 'max-height: 200px; height: 24px; overflow-y: hidden;'); - } - - chatContainer.setAttribute('last-set-index', lastSetIndex); - } - } - }); - } - } - + if (textarea.getAttribute('listener-injected') !== 'true') { + textarea.setAttribute('listener-injected', 'true'); + textarea.addEventListener('keydown', function (event) { + + // CTRL+UP or CMD+UP to navigate through user previous prompts + if ((event.ctrlKey || event.metaKey) && (event.key === 'ArrowUp')) { + + const chatContainer = document.querySelector('.h-full.dark\\:bg-gray-800'); + if (chatContainer===null) { + return; + } + + const chatbubbles = chatContainer.querySelectorAll('.flex .flex-grow .flex-col'); + + if (chatbubbles.length > 0) { + let lastSetIndex = chatContainer.getAttribute('last-set-index') ?? chatbubbles.length; + + if (event.key === 'ArrowUp') { + lastSetIndex-=2; + + if (lastSetIndex < 0) { + lastSetIndex = chatbubbles.length-2; + } + } + + const lastChatBubble = chatbubbles[lastSetIndex]; + var text = lastChatBubble.innerText + + text = text.replace('\n\nCopy to Clipboard',''); + textarea.value = text; + + // Expand the textarea if prompt is multiline otherwise keeps default size + if (text.includes('\n')) { + textarea.setAttribute('style','max-height: 200px; height: 264px;'); + } else { + textarea.setAttribute('style', 'max-height: 200px; height: 24px; overflow-y: hidden;'); + } + + chatContainer.setAttribute('last-set-index', lastSetIndex); + } + } + }); + } + } + }, 1000); })(); \ No newline at end of file diff --git a/manifest.json b/manifest.json index 3217883..aca678a 100644 --- a/manifest.json +++ b/manifest.json @@ -10,7 +10,7 @@ "128": "media/128.png" }, "description": "This extension allows you to copy chat GPT responses with a click of a button or CMD+K and runs it through plagiarism detectors", - "version": "0.3.8", + "version": "0.4.0", "host_permissions": [ "https://api.gptzero.me/*" ], From 8dbbcb57662788ec651dd21927cea0f826928b0f Mon Sep 17 00:00:00 2001 From: dliedke Date: Sat, 27 May 2023 13:10:43 -0300 Subject: [PATCH 7/9] Added CTRL+Down user prompts navigation and fixed issues with first user prompt not being copied sometimes --- init.js | 53 ++++++++++++++++++++++++++++++++++----------------- manifest.json | 2 +- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/init.js b/init.js index b6d1186..92cbd27 100644 --- a/init.js +++ b/init.js @@ -3,12 +3,12 @@ const currentYear = new Date().getFullYear() console.log(` - Copy Button: Enabled ✅ - - CMD+K Hotkey: Enabled ✅ - - Up Arrow Key: Enabled ✅ + - CTRL/CMD+K Hotkey: Enabled ✅ + - CTRL/CMD+Up/Down Arrow Key: Enabled ✅ - ✨ AI plagiarism checker: Enabled ✅ Copyright (c) ${currentYear} Sethu Senthil / Daniel Liedke - Version: 0.4.0 + Version: 0.4.1 https://copygpt.sethusenthil.com https://sethusenthil.com `) @@ -58,6 +58,7 @@ const intervalId = window.setInterval(async function () { + if (!document.querySelector('#copygpt-credits')) { var textCenterElement = document.querySelector('.text-center'); if (textCenterElement == null) { @@ -68,6 +69,15 @@ } } + // Find element with class h-4 w-4 mr-1 + const sendMessageButton = document.querySelector('.h-4.w-4.mr-1'); + + // If sendMessageButton is not found return + if (sendMessageButton === null) { + return; + } + + // If chat container is not found return const chatContainer = document.querySelector('.h-full.dark\\:bg-gray-800'); if (chatContainer===null) { return; @@ -81,22 +91,22 @@ copyUserPromptToClipboard = true; } }); - + chatbubbles.forEach((chatbox, i) => { { var text; if (chatbox.parentElement.querySelector('.copy-to-clipboard') === null && (!(!copyUserPromptToClipboard && i % 2 === 0))) { - chatbox.insertAdjacentHTML('afterend', `
-

Copy to Clipboard

clipboard emoji -
`); - chatbox.parentElement.querySelector('.copy-to-clipboard').addEventListener('click', function () { - - text = chatbox.innerText; - copyToClipboard(text); + chatbox.insertAdjacentHTML('afterend', `
+

Copy to Clipboard

clipboard emoji +
`); + chatbox.parentElement.querySelector('.copy-to-clipboard').addEventListener('click', function () { + + text = chatbox.innerText; + copyToClipboard(text); - }); + }); } } }); @@ -128,12 +138,12 @@ const textarea = document.querySelector('textarea'); - if (textarea.getAttribute('listener-injected') !== 'true') { + if (textarea!==null && textarea.getAttribute('listener-injected') !== 'true') { textarea.setAttribute('listener-injected', 'true'); textarea.addEventListener('keydown', function (event) { // CTRL+UP or CMD+UP to navigate through user previous prompts - if ((event.ctrlKey || event.metaKey) && (event.key === 'ArrowUp')) { + if ((event.ctrlKey || event.metaKey) && (event.key === 'ArrowUp' || event.key === 'ArrowDown')) { const chatContainer = document.querySelector('.h-full.dark\\:bg-gray-800'); if (chatContainer===null) { @@ -143,16 +153,25 @@ const chatbubbles = chatContainer.querySelectorAll('.flex .flex-grow .flex-col'); if (chatbubbles.length > 0) { - let lastSetIndex = chatContainer.getAttribute('last-set-index') ?? chatbubbles.length; + let lastSetIndex = +chatContainer.getAttribute('last-set-index') ?? chatbubbles.length; + if (event.key === 'ArrowUp') { - lastSetIndex-=2; + lastSetIndex = lastSetIndex -2; if (lastSetIndex < 0) { lastSetIndex = chatbubbles.length-2; } } + if (event.key === 'ArrowDown') { + lastSetIndex = lastSetIndex + 2; + + if (lastSetIndex >= chatbubbles.length) { + lastSetIndex = 0; + } + } + const lastChatBubble = chatbubbles[lastSetIndex]; var text = lastChatBubble.innerText @@ -173,6 +192,6 @@ } } - }, 1000); + }, 2000); })(); \ No newline at end of file diff --git a/manifest.json b/manifest.json index aca678a..9039712 100644 --- a/manifest.json +++ b/manifest.json @@ -10,7 +10,7 @@ "128": "media/128.png" }, "description": "This extension allows you to copy chat GPT responses with a click of a button or CMD+K and runs it through plagiarism detectors", - "version": "0.4.0", + "version": "0.4.1", "host_permissions": [ "https://api.gptzero.me/*" ], From 64900e2197cdf7e92fa50ee3c612e173a149a3c4 Mon Sep 17 00:00:00 2001 From: dliedke Date: Thu, 1 Jun 2023 19:43:15 -0300 Subject: [PATCH 8/9] Fix integration issues --- Copy-for-ChatGPT.code-workspace | 7 +++++++ init.js | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 Copy-for-ChatGPT.code-workspace diff --git a/Copy-for-ChatGPT.code-workspace b/Copy-for-ChatGPT.code-workspace new file mode 100644 index 0000000..362d7c2 --- /dev/null +++ b/Copy-for-ChatGPT.code-workspace @@ -0,0 +1,7 @@ +{ + "folders": [ + { + "path": "." + } + ] +} \ No newline at end of file diff --git a/init.js b/init.js index 92cbd27..9af7c00 100644 --- a/init.js +++ b/init.js @@ -69,8 +69,8 @@ } } - // Find element with class h-4 w-4 mr-1 - const sendMessageButton = document.querySelector('.h-4.w-4.mr-1'); + // Find send message button element with class .h-4.w-4.m-1.md\\:m-0 + const sendMessageButton = document.querySelector('.h-4.w-4.m-1.md\\:m-0'); // If sendMessageButton is not found return if (sendMessageButton === null) { @@ -78,7 +78,7 @@ } // If chat container is not found return - const chatContainer = document.querySelector('.h-full.dark\\:bg-gray-800'); + const chatContainer = document.querySelector('.dark\\:bg-gray-800'); if (chatContainer===null) { return; } @@ -114,7 +114,7 @@ if (chatContainer.getAttribute('listener-injected') !== 'true') { document.addEventListener('keydown', function (event) { - const chatContainer = document.querySelector('.h-full.dark\\:bg-gray-800'); + const chatContainer = document.querySelector('.dark\\:bg-gray-800'); if (chatContainer===null) { return; } @@ -145,7 +145,7 @@ // CTRL+UP or CMD+UP to navigate through user previous prompts if ((event.ctrlKey || event.metaKey) && (event.key === 'ArrowUp' || event.key === 'ArrowDown')) { - const chatContainer = document.querySelector('.h-full.dark\\:bg-gray-800'); + const chatContainer = document.querySelector('.dark\\:bg-gray-800'); if (chatContainer===null) { return; } From 244f3abddf97a1455e33099187748f8e7cf699af Mon Sep 17 00:00:00 2001 From: dliedke Date: Sat, 16 Sep 2023 13:59:36 -0300 Subject: [PATCH 9/9] Fix for GPT august 3rd version --- init.js | 25 +++++++++++++++---------- manifest.json | 4 ++-- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/init.js b/init.js index 9af7c00..3cc873e 100644 --- a/init.js +++ b/init.js @@ -8,12 +8,17 @@ - ✨ AI plagiarism checker: Enabled ✅ Copyright (c) ${currentYear} Sethu Senthil / Daniel Liedke - Version: 0.4.1 + Version: 0.5.0 https://copygpt.sethusenthil.com https://sethusenthil.com `) + const CHAT_CONTAINER_SELECTOR = '.flex.flex-col.text-sm.dark\\:bg-gray-800'; + const CHAT_BUBLES_SELECTOR = '.flex.flex-grow.flex-col.gap-3.max-w-full'; const CHAT_TEXT_SELECTOR = '.markdown'; + const CHAT_USER_MESSAGE_SELECTOR = '#prompt-textarea'; + const CHAT_SEND_MESSAGE_BUTTON_SELECTOR = '.icon-sm.m-1.md\\:m-0'; + var copyUserPromptToClipboard = false; const showSnackbar = (message, position) => { @@ -69,8 +74,8 @@ } } - // Find send message button element with class .h-4.w-4.m-1.md\\:m-0 - const sendMessageButton = document.querySelector('.h-4.w-4.m-1.md\\:m-0'); + // Find send message button element with class .icon-sm.m-1.md\\:m-0 + const sendMessageButton = document.querySelector(CHAT_SEND_MESSAGE_BUTTON_SELECTOR); // If sendMessageButton is not found return if (sendMessageButton === null) { @@ -78,12 +83,12 @@ } // If chat container is not found return - const chatContainer = document.querySelector('.dark\\:bg-gray-800'); + const chatContainer = document.querySelector(CHAT_CONTAINER_SELECTOR); if (chatContainer===null) { return; } - const chatbubbles = chatContainer.querySelectorAll('.flex .flex-grow .flex-col'); + const chatbubbles = document.querySelectorAll(CHAT_BUBLES_SELECTOR); //check if copyUserPromptToClipboard is enabled chrome.storage.sync.get('copyUserPromptToClipboard', function(settings) { @@ -114,7 +119,7 @@ if (chatContainer.getAttribute('listener-injected') !== 'true') { document.addEventListener('keydown', function (event) { - const chatContainer = document.querySelector('.dark\\:bg-gray-800'); + const chatContainer = document.querySelector(CHAT_CONTAINER_SELECTOR); if (chatContainer===null) { return; } @@ -122,7 +127,7 @@ // check for CTRL+K on Windows or CMD+K on Mac if ((event.ctrlKey || event.metaKey) && event.keyCode === 75) { - const chatbubbles = chatContainer.querySelectorAll('.flex .flex-grow .flex-col'); + const chatbubbles = document.querySelectorAll(CHAT_BUBLES_SELECTOR); if (chatbubbles.length % 2 === 0) { @@ -136,7 +141,7 @@ chatContainer.setAttribute('listener-injected', 'true'); }); - const textarea = document.querySelector('textarea'); + const textarea = document.querySelector(CHAT_USER_MESSAGE_SELECTOR); if (textarea!==null && textarea.getAttribute('listener-injected') !== 'true') { textarea.setAttribute('listener-injected', 'true'); @@ -145,12 +150,12 @@ // CTRL+UP or CMD+UP to navigate through user previous prompts if ((event.ctrlKey || event.metaKey) && (event.key === 'ArrowUp' || event.key === 'ArrowDown')) { - const chatContainer = document.querySelector('.dark\\:bg-gray-800'); + const chatContainer = document.querySelector(CHAT_CONTAINER_SELECTOR); if (chatContainer===null) { return; } - const chatbubbles = chatContainer.querySelectorAll('.flex .flex-grow .flex-col'); + const chatbubbles = document.querySelectorAll(CHAT_BUBLES_SELECTOR); if (chatbubbles.length > 0) { diff --git a/manifest.json b/manifest.json index 9039712..898345a 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "manifest_version": 3, - "author": "Sethu Senthil", + "author": "Sethu Senthil/Daniel Liedke", "name": "Copy for Chat GPT", "icons": { "16": "media/16.png", @@ -10,7 +10,7 @@ "128": "media/128.png" }, "description": "This extension allows you to copy chat GPT responses with a click of a button or CMD+K and runs it through plagiarism detectors", - "version": "0.4.1", + "version": "0.5.0", "host_permissions": [ "https://api.gptzero.me/*" ],