Created
December 5, 2022 23:33
-
-
Save nikhiljha/c3677297dc86979450b8b8749348afc0 to your computer and use it in GitHub Desktop.
chatgpt arbitrary code execution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Connect ChatGPT to the Internet | |
// @namespace https://chat.openai.com/ | |
// @version 0.1 | |
// @description Because why not! | |
// @author You | |
// @match https://chat.openai.com/chat | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
setInterval(function() { | |
var hljsElems = document.getElementsByClassName("hljs"); | |
for (var i = 0; i < hljsElems.length; i++) { | |
var hljsElem = hljsElems[i]; | |
if (!hljsElem.classList.contains("injected")) { | |
var textContent = hljsElem.textContent; | |
// Check if the textContent is a script tag | |
if (textContent.trim().startsWith("<script>")) { | |
// If it is, use eval to execute the script | |
eval(textContent.trim().replace(/^<script>/, "").replace(/<\/script>$/, "")); | |
} else { | |
// Otherwise, create a new element to hold the textContent | |
var newElement = document.createElement("span"); | |
newElement.innerHTML = textContent; | |
// Append the new element after the parent of the hljs element | |
hljsElement.parentNode.appendChild(newElement); | |
} | |
hljsElem.classList.add("injected"); | |
} | |
} | |
}, 5000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment