Skip to content

Instantly share code, notes, and snippets.

@jhauga
Last active November 13, 2024 22:33
Show Gist options
  • Save jhauga/0910c78eef852fc381464db7cfae49ab to your computer and use it in GitHub Desktop.
Save jhauga/0910c78eef852fc381464db7cfae49ab to your computer and use it in GitHub Desktop.
Bookmarklet - use this bookmarklet for Bookmark the contents of a Generative AI response from Google search. Run bookmarklet, and then paste contents into new bookmark. Ensure to copy/paste the top condensed line of the bookmarklet. Info at "https://github.com/isocialPractice/bookmarklets".
/// *********************************************************** ///
// ****************** BROWSER BOOKMARKLET GIST ***************** //
// ************************************************************* //
// //
// LICENSE /////////////////////////////////////////////////////
// ******* //
// The code in this gist is public domain. //
// Licensed as Public Domain CC0 //
//////////////////////////////////////////////////////////////////
//
// COPY / PAST BELOW LINE TO USE
javascript:(function(){ var pageTitle = "Google Generative AI Bookmark"; /* OPTIONAL - Change title. */ var answerDiv = document.getElementsByClassName("UxeQfc"); /* HOT-GLUE - classname holding answer HTML */ var answerDivHTML = answerDiv[0].innerHTML; /* One element with class name "CAYQBw" */ var pageStyle = `<style> /* USER EDITED *//******************************/:root { --m3c1: #0b57d0; --m3c2: rgba(247, 248, 249, 0.5); --m3c3: #fff; --m3c5: #f4f6f7; --m3c6: #f7f8f9; --m3c7: #ecedee; --m3c9: #1f1f1f; --m3c10: #5e5e5e; --m3c11: #474747; --m3c12: #1a0dab; --m3c13: #a3c9ff; --m3c14: #001d35; --m3c15: #0b57d0; --m3c16: #5e5e5e; --m3c17: #d2d2d2; --m3c18: #446eff; --m3c19: #b1c5ff; --m3c20: #c8ecff; --m3c21: #a6c8ff; --m3c22: #ecedee; --m3c23: #3179ed;}/* Hide dynamic elements */div span.Txngnb,div span.wHYlTd,div span.yUTMj,div span.E80BZc,div.EYbnVe.ZpdbId,div.EYbnVe,div.WDoJJe,.ZpdbId,svg,div.n2i4Qd,.CcNe6e,button { display: none !important;}body { margin-left: 30px;}h1, h2, h3, h4, h5, h6, p { font-family: Google Sans, Roboto, Arial, sans-serif;}div.jK2eDe.ZpdbId { background: none !important; z-index: -1;}span { font-family: Google Sans, Roboto, Arial, sans-serif; font-style: normal; font-weight: 400; font-size: 18px; line-height: 24px; }code * { font-family: monospace; padding: 0px; background: transparent; }div.WaaZC { margin-top: 10px;}div.WaaZC div div div div div { background: rgba(0,0,0,.05);}div div div div div span { background-color: rgba(0,0,0,0) !important;}.hdzaWe { font-family: Google Sans, Roboto, Arial, sans-serif; position: relative}/* COPY AND PASTE FROM GOOGLE *//******************************/.LT6XE, .zNsLfb { overflow-wrap: break-word; max-width: 632px;}.a7yfkb { color: #80868b; font-style: italic}.VQ2nqe { color: #c5221f}.mFP83e, .Bkvjgc, .Uw0eSc { color: #b45908}.gZdC2c { color: #996900}.rQeGvc { color: #188038}.RWHSsb, .z9fBwb, .quIshb { color: #1967d2}.aPB6vc, .TyFvzb, .VSzkzc { color: #9334e6}.Vm8mDc, .VURuic { color: #9334e6}.Vm8mDc { font-weight: bold}.zYSUYd { display: flex; background: transparent !important; flex-direction: row; overflow: hidden; border-radius: 8px 8px 0 0}.QQjpRc { display: flex; flex-direction: row; overflow: hidden; border-radius: 0 0 8px 8px;}.FS7GEb { display: flex; flex-direction: column; flex-grow: 1; min-width: 38%; width: 80%}.FS7GEb pre { margin: 0; display: inline-grid}.FS7GEb code { font-family: monospace; display: block; padding: 16px 16px 22px; line-height: 22px; background: transparent; overflow-x: auto;}.dDrxod { height: 34px; display: flex; background-color: transparent !important; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--m3c17);}.x7ndcb { padding-left: 15px; background-color: transparent !important; display: flex; align-items: center;}.hqI3tf { background: none; height: 34px; border: none; position: relative; top: 2px}</style>%60; /************************************************************* Clean up contents a bit. */ answerDivHTML = answerDivHTML.replace(/\n/g, "<br>"); answerDivHTML = answerDivHTML.replace(/\"/g, '&#92;&quot;'); answerDivHTML = answerDivHTML.replace(/"/g, '\"'); answerDivHTML = answerDivHTML.replace(/\'/g, "&#92;&apos;'"); answerDivHTML = answerDivHTML.replace(/'/g, "'"); answerDivHTML = answerDivHTML.replace(/([ ]{2,})/g, "<br>$1"); answerDivHTML = answerDivHTML.replace(/%/g, "\%"); /************************************************************* Make bookmarklet with answer bookmarked. */ var copiedAnswer = 'javascript:(function() {document.write("' + /* write html head content */ "<!DOCTYPE HTML><html><head><title>" + pageTitle + "</title>" + /* add style */ pageStyle + /* close head html and start body of page */ "</head><body><h1>Google Generative AI</h1><hr>" + /* sidebarlink to original answer */ '<h3>Google Generative AI Bookmark</h3>' + /* output copied content */ answerDivHTML + /* close html */ "</body></html>" + /* close bookmarklet */ '");})()'; /************************************************************* Remove unwanted escaped double quotes. */ copiedAnswer = copiedAnswer.replace(/&#92;&quot;/g, '\\"'); /************************************************************* 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. */})();
// MAKE ANY EDITS AS NEEDED
// *************************************************************
// Use the JS Formatted Bookmarklet below to see if any changes
// need to be made in accordance to the page you want to use
// it for. After making needed changes ensure that the revised
// bookmarklet is condensed before using it in your browser.
// For more info on this bookmarklet visit:
// https://github.com/isocialPractice/bookmarklets
// *************************************************************
// *************************************************************
// ************************JS-FORMATTED*************************
javascript:(function(){
var pageTitle = "Google Generative AI Bookmark"; /* OPTIONAL - Change title. */
var answerDiv = document.getElementsByClassName("UxeQfc"); /* HOT-GLUE - classname holding answer HTML */
var answerDivHTML = answerDiv[0].innerHTML; /* One element with class name "CAYQBw" */
var pageStyle = `
<style>
/* USER EDITED */
/******************************/
:root {
--m3c1: #0b57d0;
--m3c2: rgba(247, 248, 249, 0.5);
--m3c3: #fff;
--m3c5: #f4f6f7;
--m3c6: #f7f8f9;
--m3c7: #ecedee;
--m3c9: #1f1f1f;
--m3c10: #5e5e5e;
--m3c11: #474747;
--m3c12: #1a0dab;
--m3c13: #a3c9ff;
--m3c14: #001d35;
--m3c15: #0b57d0;
--m3c16: #5e5e5e;
--m3c17: #d2d2d2;
--m3c18: #446eff;
--m3c19: #b1c5ff;
--m3c20: #c8ecff;
--m3c21: #a6c8ff;
--m3c22: #ecedee;
--m3c23: #3179ed;
}
/* Hide dynamic elements */
div span.Txngnb,
div span.wHYlTd,
div span.yUTMj,
div span.E80BZc,
div.EYbnVe.ZpdbId,
div.EYbnVe,
div.WDoJJe,
.ZpdbId,
svg,
div.n2i4Qd,
.CcNe6e,
button {
display: none !important;
}
body {
margin-left: 30px;
}
h1, h2, h3, h4, h5, h6, p {
font-family: Google Sans, Roboto, Arial, sans-serif;
}
div.jK2eDe.ZpdbId {
background: none !important;
z-index: -1;
}
span {
font-family: Google Sans, Roboto, Arial, sans-serif;
font-style: normal;
font-weight: 400;
font-size: 18px;
line-height: 24px;
}
code * {
font-family: monospace;
padding: 0px;
background: transparent;
}
div.WaaZC {
margin-top: 10px;
}
div.WaaZC div div div div div {
background: rgba(0,0,0,.05);
}
div div div div div span {
background-color: rgba(0,0,0,0) !important;
}
.hdzaWe {
font-family: Google Sans, Roboto, Arial, sans-serif;
position: relative
}
/* COPY AND PASTE FROM GOOGLE */
/******************************/
.LT6XE, .zNsLfb {
overflow-wrap: break-word;
max-width: 632px;
}
.a7yfkb {
color: #80868b;
font-style: italic
}
.VQ2nqe {
color: #c5221f
}
.mFP83e, .Bkvjgc, .Uw0eSc {
color: #b45908
}
.gZdC2c {
color: #996900
}
.rQeGvc {
color: #188038
}
.RWHSsb, .z9fBwb, .quIshb {
color: #1967d2
}
.aPB6vc, .TyFvzb, .VSzkzc {
color: #9334e6
}
.Vm8mDc, .VURuic {
color: #9334e6
}
.Vm8mDc {
font-weight: bold
}
.zYSUYd {
display: flex;
background: transparent !important;
flex-direction: row;
overflow: hidden;
border-radius: 8px 8px 0 0
}
.QQjpRc {
display: flex;
flex-direction: row;
overflow: hidden;
border-radius: 0 0 8px 8px;
}
.FS7GEb {
display: flex;
flex-direction: column;
flex-grow: 1;
min-width: 38%;
width: 80%
}
.FS7GEb pre {
margin: 0;
display: inline-grid
}
.FS7GEb code {
font-family: monospace;
display: block;
padding: 16px 16px 22px;
line-height: 22px;
background: transparent;
overflow-x: auto;
}
.dDrxod {
height: 34px;
display: flex;
background-color: transparent !important;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid var(--m3c17);
}
.x7ndcb {
padding-left: 15px;
background-color: transparent !important;
display: flex;
align-items: center;
}
.hqI3tf {
background: none;
height: 34px;
border: none;
position: relative;
top: 2px
}
</style>`;
/************************************************************* Clean up contents a bit. */
answerDivHTML = answerDivHTML.replace(/\n/g, "<br>");
answerDivHTML = answerDivHTML.replace(/\"/g, '&#92;&quot;');
answerDivHTML = answerDivHTML.replace(/"/g, '\"');
answerDivHTML = answerDivHTML.replace(/\'/g, "&#92;&apos;'");
answerDivHTML = answerDivHTML.replace(/'/g, "'");
answerDivHTML = answerDivHTML.replace(/([ ]{2,})/g, "<br>$1");
answerDivHTML = answerDivHTML.replace(/%/g, "\%");
/************************************************************* Make bookmarklet with answer bookmarked. */
var copiedAnswer = 'javascript:(function() {document.write("' +
/* write html head content */
"<!DOCTYPE HTML><html><head><title>" + pageTitle + "</title>" +
/* add style */
pageStyle +
/* close head html and start body of page */
"</head><body><h1>Google Generative AI</h1><hr>" +
/* sidebarlink to original answer */
'<h3>Google Generative AI Bookmark</h3>' +
/* output copied content */
answerDivHTML +
/* close html */
"</body></html>" +
/* close bookmarklet */
'");})()';
/************************************************************* Remove unwanted escaped double quotes. */
copiedAnswer = copiedAnswer.replace(/&#92;&quot;/g, '\\"');
/************************************************************* 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. */
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment