Skip to content

Instantly share code, notes, and snippets.

@danthedaniel
Last active February 27, 2017 20:27
Show Gist options
  • Save danthedaniel/2b8fc2c38344d431857e32b6595c72e7 to your computer and use it in GitHub Desktop.
Save danthedaniel/2b8fc2c38344d431857e32b6595c72e7 to your computer and use it in GitHub Desktop.
Automatically generate a CSV from a page of GitHub issues
/* This script is meant to be ran in the development console of your browser,
* and executed while on the GitHub issues page.
* Edit it as needed to match your issues.
*/
var query_list = (elem, query) => {
return Array.prototype.slice.call(elem.querySelectorAll(query));
};
var priority_labels = ['High', 'Medium', 'Low'];
var approved_label = 'Approved';
var deployed_label = 'Deployed';
query_list(document, 'li[id^="issue_"').map(issue => {
var labels = query_list(issue, '.labels > a').map(label => {
return label.innerText.trim();
});
var priority = labels.find(label => priority_labels.includes(label));
var deployed = labels.includes(deployed_label) ? 'Yes' : 'No';
var approved = labels.includes(approved_label) ? 'Yes' : 'No';
var issue_text = issue.querySelector('.lh-condensed > a').innerText.trim();
return [
priority,
deployed,
approved,
'"' + issue_text.replace(/[\\"']/g, '\\$&') + '"' // Escape double quotes
].join(',');
}).join('\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment