Extracting a Trello board as markdown
(or "web scraping from the chrome console, with jquery")
Assuming you use Trello and the Chrome browser, here's a technique for extracting a trello board onto your clipboard as plain text.
Navigate to the Trello board you want to grab, and bring up the chrome developer tools ([F12], or [Ctrl]+[Shift]+[I], or Tools → Developer Tools)
Go to the console () -- and enter this piece of javascript. (Don't read it.... just enter it... trust me).
var s = [];var x;s.push("# " + $("#board-header").children()[0].innerText); $(".list:has(.list-title)").each(function() { x = this.innerHTML; s.push("## " + $(this).find(".list-title")[0].innerText);$(this).find(".list-card-title").each(function() { s.push("* " + this.innerText); }); }); copy(s.join("\n"));
Okay -- spaced out over a couple of lines it reads:
var s = []; s.push("# " + $("#board-header").children()[0].innerText); $(".list:has(.list-title)").each(function() { s.push("## " + $(this).find(".list-title")[0].innerText); $(this).find(".list-card-title").each(function() { s.push("* " + this.innerText); }); }); copy(s.join("\n"));
The whole trello board will now be on your clipboard, in nature's favorite format: markdown.
Use the intrinsic 'copy
' function to copy a value to the clipboard
One lesson I learnt while putting this together: you can use copy
in the console to put a value onto the clipboard. This doesn't work in regular pages, for security reasons.
Inject jQuery into a page
If you want to use this kind of data-extraction technique on a page that doesn't have jQuery, then you'll want a simple technique for injecting jQuery into a page.
Just pop down to the console and paste this:
var script = document.createElement("script"); script.src = "http://code.jquery.com/jquery-latest.min.js"; document.body.appendChild(script);
jQuery will now be available on that page, and you can sizzle to your heart's content.
Caveats:
- You may first want to make sure jquery isn't already loaded.
- And you have to make sure the 'script' variable doesn't overwrite any existing variable of the same name.
- You may want a specific jQuery version.
- Use at your own risk, no warranty or replacement for lost limbs etc.
My book "Choose Your First Product" is available now.
It gives you 4 easy steps to find and validate a humble product idea.