javascript:(function(){ var pageTitle = "Google Generative AI Bookmark"; /* OPTIONAL - Change title. */ /* HOT-GLUE - classname holding answer HTML */ var answerDiv = document.querySelectorAll(".UxeQfc, .mZJni.Dn7Fzd"); var answerDivHTML = answerDiv[0].innerHTML; /* One element with class name "CAYQBw" */ var pageScript = ` `; var pageStyle = ` `; /************************************************************* Clean up contents a bit. */ answerDivHTML = answerDivHTML.replaceAll(/\n/g, "
"); answerDivHTML = answerDivHTML.replaceAll(/\\"/g, '\"'); answerDivHTML = answerDivHTML.replaceAll(/\"/g, '"'); answerDivHTML = answerDivHTML.replaceAll(/"/g, '\"'); answerDivHTML = answerDivHTML.replaceAll(/\\'/g, "\''"); answerDivHTML = answerDivHTML.replaceAll(/'/g, "'"); answerDivHTML = answerDivHTML.replaceAll(/([ ]{2,})/g, "
$1"); answerDivHTML = answerDivHTML.replaceAll(/%/g, "\\%"); answerDivHTML = answerDivHTML.replaceAll(/\(/g, "("); answerDivHTML = answerDivHTML.replaceAll(/\)/g, ")"); answerDivHTML = answerDivHTML.replaceAll(/\&/g, "&"); /************************************************************* Make bookmarklet with answer bookmarked. */ var copiedAnswer = 'javascript:(function() {document.write("' + /* write html head content */ "" + pageTitle + "" + /* add style */ pageStyle + /* close head html and start body of page */ "

Google Generative AI


" + /* sidebarlink to original answer */ '

Google Generative AI Bookmark

' + /* output copied content */ answerDivHTML + pageScript + /* close html */ "" + /* close bookmarklet */ '");})()'; /************************************************************* Remove unwanted escaped double quotes. */ copiedAnswer = copiedAnswer.replaceAll(/\"/g, ''); copiedAnswer = copiedAnswer.replaceAll("(", "("); copiedAnswer = copiedAnswer.replaceAll(")", ")"); copiedAnswer = copiedAnswer.replaceAll("&", "&"); /************************************************************* Mind delay to ensure all is copied. */ alert("Wait 1 seconds to ensure all of the answer " + "\n is copied to clipboard."); /************************************************************* Copy to clipboard to make new bookmark */ setTimeout(function() { /* Use current answer in new bookmarkelet */ navigator.clipboard.writeText(copiedAnswer); /* that will write out HTML to page. */ }, 1000); /* Copy HTML to clipboard after 1 second. */ })();