Skip to content

Instantly share code, notes, and snippets.

@liuderchi
Last active April 3, 2020 09:49
Show Gist options
  • Save liuderchi/11af933a4a0483f2b67843955f2dc7a2 to your computer and use it in GitHub Desktop.
Save liuderchi/11af933a4a0483f2b67843955f2dc7a2 to your computer and use it in GitHub Desktop.
// modified ghParsePrSearch.js https://gist.github.com/liuderchi/a20952af0b26eca37ce9afab6875c365
var comments = [
...document.querySelectorAll('.notion-page-view-discussion')[0].firstElementChild.firstElementChild.children
].slice(0, -1); // remove empty one in the end
var res = comments
.map(div => {
const dateContent = div.children[1].children[0].children[1].textContent;
const dateString = dateContent.match(/(\d\d\/){2}\d{4}/i)?.[0] ? `@${dateContent.match(/(\d\d\/){2}\d{4}/i)?.[0]}` : ''
const comment = div.children[1].children[1].textContent;
return `- ${dateString} ${comment}`
})
.join('\n');
window.prompt("Copy to clipboard: cmd+C, Enter", res);
// make it a bookmarklet https://mrcoles.com/bookmarklet/ (remember to remove comments in snippet)
// javascript:(function()%7Bvar%20comments%20%3D%20%5B...document.querySelectorAll('.notion-page-view-discussion')%5B0%5D.firstElementChild.firstElementChild.children%5D.slice(0%2C%20-1)%3Bwindow.prompt(%22Copy%20to%20clipboard%3A%20cmd%2BC%2C%20Enter%22%2Ccomments.map(div%20%3D%3E%20%60-%20%24%7Bdiv.children%5B1%5D.children%5B1%5D.textContent%7D%60).join('%5Cn'))%7D)()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment