Last active
October 27, 2019 15:19
-
-
Save Benjamin-Dobell/c1d94878d1d0343ae506af6beef901cc to your computer and use it in GitHub Desktop.
all-cards-to-issues.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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