Skip to content

Instantly share code, notes, and snippets.

@thibaultmol
Created December 31, 2022 11:46
Show Gist options
  • Save thibaultmol/1c6b55f023bc1c64ca02da877d41ca39 to your computer and use it in GitHub Desktop.
Save thibaultmol/1c6b55f023bc1c64ca02da877d41ca39 to your computer and use it in GitHub Desktop.
JS bookmarklet to take text from webpage, add gpt prompt, copy to clipboard. Ready to paste into ChatGPT
javascript:(function(){var t="",a=document.querySelectorAll("p,h1,h2,h3,h4,h5,h6,td,th,li,dt,dd");for(i=0;i<a.length;i++){if(a[i].nodeType==1){t+=a[i].textContent+"\n"}}var l=document.querySelectorAll("a");for(i=0;i<l.length;i++){if(!l[i].href.endsWith(".jpg") && !l[i].href.endsWith(".jpeg") && !l[i].href.endsWith(".png") && !l[i].href.endsWith(".gif")){t+=l[i].textContent+" ("+l[i].href+")\n"}}t=t.split("\n");for(i=0;i<t.length;i++){if(t[i].includes("<img")){var c=1;while(!t[i+c].includes(">")){c++}t.splice(i,c+1);i--}}t=t.join("\n");t=t.replace(/^\s*[\r\n]/gm,"");t="addr:housenumber=\naddr:street=\ncontact:facebook=\ncontact:instagram=\nemail=\nphone=\nopening_hours=\nref:vatin=\n\nExtract from the text below the openstreetmap tags mentioned above. Make sure everything is formatted according to Openstreetmap's conventions.\n\"ref:vatin\" should be formatted without spaces; in one continuous number (no dots/points).\nPhone should be formatted with country code +32\nDon't add data when you're not sure about it.\n\n"+t;navigator.clipboard.writeText(t)})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment