Skip to content

Instantly share code, notes, and snippets.

@shevchenkoartem
Last active February 26, 2024 04:04
Show Gist options
  • Save shevchenkoartem/78f55930105ca2acedc8d3542f24f4aa to your computer and use it in GitHub Desktop.
Save shevchenkoartem/78f55930105ca2acedc8d3542f24f4aa to your computer and use it in GitHub Desktop.
Bookmarklet (script instead of URL for a bookmark) to copy markdown on FunRetrospectives page with a table. Then in Confluence, paste it to Markdown element (find it in Insert (+) menu when editing a page)

You can use this script if you would like to export the result table from FunRetrospectives to Confluence.

  1. Copy the content of the JS-file to the clipboard.
  2. Open Chrome and display the bookmarks bar if it's not already visible (press Ctrl+Shift+B or Cmd+Shift+B on a Mac).
  3. Right-click on the bookmarks bar, and choose "Add page" or "Add new bookmark."
  4. In the "Name" field, enter a name for the bookmarklet (e.g., "Export Table From FunRetrospectives").
  5. In the "URL" field, paste the single-line JavaScript code you copied in step 1.
  6. Click "Save."

Now you can copy the markdown for Confluence by clicking the bookmark on FunRetrospectives page with table.

Then in Confluence page editing mode::

  1. Choose Insert ('+' icon in the menu) > Markdown
  2. Paste into "Insert text" (the markdown text is already in the clipboard)
  3. Click "Save."

Voilà!

javascript:(function(){function getComments(){const t=document.querySelectorAll(".col.board-col");return Array.from(t).reduce(((t,e)=>{const r=e.querySelector(".title.align-items-center span").textContent,n=e.querySelectorAll(".board-item__input.align-items-center"),o=Array.from(n).reduce(((t,e,r)=>{const n=e.textContent.trim();return r%2==0?t.push([n]):"Action Item..."!==n&&t[t.length-1].push(n),t}),[]);return t.set(r,o),t}),new Map)}function getCommentsTableMarkup(t){const e=Array.from(t.keys()).map((t=>`| ${t}`)).join(" ")+" |",r=Array.from(t.keys()).map((()=>"| ---")).join(" ")+" |",n=Math.max(...Array.from(t.values(),(t=>t.length)));return`${e}\n${r}\n${Array.from({length:n},((e,r)=>Array.from(t.values(),(t=>{const[e="",n=""]=t[r]||[];return n?`| ${e} \`\`\`Action: ${n}\`\`\``:`| ${e}`})).join(" ")+" |")).join("\n")}`}async function copyToClipboard(t){try{await navigator.clipboard.writeText(t),alert("Text copied to clipboard.")}catch(t){alert("Failed to copy text. Please try again.")}}const commentsInColumns=getComments(),tableMarkup=getCommentsTableMarkup(commentsInColumns);copyToClipboard(tableMarkup);})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment