diff --git a/chatgpt-addon.user.js b/chatgpt-addon.user.js index 75f729a..36e9862 100644 --- a/chatgpt-addon.user.js +++ b/chatgpt-addon.user.js @@ -1,13 +1,44 @@ // ==UserScript== -// @name New script chatgpt.com -// @namespace Violentmonkey Scripts +// @name ZennGPT add new features +// @namespace zennscript // @match https://chatgpt.com/c/* -// @grant none // @version 1.0 -// @author - -// @description 21.5.2024, 07:19:14 +// @author https://github.com/ZennDev1337/ +// @description LoL XD +// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js +// @require https://gist.github.com/raw/2625891/waitForKeyElements.js +// @grant GM_addStyle // ==/UserScript== +/*- The @grant directive is needed to work around a major design + change introduced in GM 1.0. It restores the sandbox. -let hallo = document.getElementsByClassName("group/conversation-turn"); + If in Tampermonkey, use "// @unwrap" to enable sandbox instead. +*/ -console.log(hallo); +waitForKeyElements(".agent-turn", actionFunction, true); + +function actionFunction(jNode) { + let agentHTMLElement = $(".agent-turn"); + for (let elm of agentHTMLElement.toArray()) { + chatMessages.push($(elm).find(".text-message")); + + $(elm) + .find(".flex.items-center") + .find("button.rounded-lg.text-token-text-secondary") + .children() + .eq(1) + .off("click") + .on("click", copyTextValidator); + } +} + +function copyTextValidator(e) { + let text = $(this) + .closest("div.agent-turn") + .find(".text-message")[0].innerText; + let result = text.replace(/ß/g, "ss"); + let regex = /(.*\n)Code kopieren\n/g; + result = text.replace(regex, "$1\n"); + navigator.clipboard.writeText(result); + console.log(result); +}