Skip to content

Instantly share code, notes, and snippets.

@nikhiljha
Created December 5, 2022 23:33
Show Gist options
  • Save nikhiljha/c3677297dc86979450b8b8749348afc0 to your computer and use it in GitHub Desktop.
Save nikhiljha/c3677297dc86979450b8b8749348afc0 to your computer and use it in GitHub Desktop.
chatgpt arbitrary code execution
// ==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