Skip to content

Instantly share code, notes, and snippets.

@Benjamin-Dobell
Last active October 27, 2019 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Benjamin-Dobell/c1d94878d1d0343ae506af6beef901cc to your computer and use it in GitHub Desktop.
Save Benjamin-Dobell/c1d94878d1d0343ae506af6beef901cc to your computer and use it in GitHub Desktop.
all-cards-to-issues.js
const PROJECT_BOARD_URL = "https://github.com/glassechidna/prototypeinertia/projects/2"
document.querySelectorAll('.issue-card').forEach(function(node) {
if (node.getAttribute('data-card-type') == "[\"issue\"]") { return }
var cardId = node.getAttribute('data-card-id');
var title = node.querySelector('.js-comment-body > p').textContent
var authenticityToken = node.querySelector('template').content.querySelector('input[name="authenticity_token"').value
var clientUid = document.querySelectorAll('.issue-card')[1].querySelector('template').content.querySelector('input[name="client_uid"').value
if (!title) {
console.error("shit no title")
}
if (!authenticityToken) {
console.error("shit no authenticity token")
}
if (!clientUid) {
console.error("shit no client uid")
}
var form = new FormData()
form.append("utf8", true)
form.append("authenticity_token", authenticityToken)
form.append("client_uid", clientUid)
form.append("title", title)
form.append("body", "")
fetch(PROJECT_BOARD_URL + "/notes/" + cardId + "/convert_to_issue", {method: 'post', credentials: 'same-origin', body: form})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment