MCPcopy Index your code
hub / github.com/ChinaGodMan/UserScripts / createIssue

Function createIssue

web-clipper/web-clipper.user.js:973–998  ·  view source on GitHub ↗
(token, owner, repo, title, body, labels = [])

Source from the content-addressed store, hash-verified

971 }
972 })
973 function createIssue(token, owner, repo, title, body, labels = []) {
974 const url = `https://api.github.com/repos/${owner}/${repo}/issues`
975 const issueData = {
976 title: title,
977 body: body,
978 labels: labels
979 }
980 const xhr = new XMLHttpRequest()
981 xhr.open('POST', url, true)
982 xhr.setRequestHeader('Authorization', `token ${token}`)
983 xhr.setRequestHeader('Accept', 'application/vnd.github+json')
984 xhr.setRequestHeader('Content-Type', 'application/json')
985 xhr.onreadystatechange = function () {
986 if (xhr.readyState === 4) {
987 if (xhr.status >= 200 && xhr.status < 300) {
988 const response = JSON.parse(xhr.responseText)
989 showDialog(translate.github_success, response.html_url)
990
991 } else {
992 alert(`${translate.github_failed}\n ${xhr.status}\n ${xhr.statusText}\n ${xhr.responseText}`)
993 console.error(`${translate.github_failed}`, xhr.status, xhr.statusText, xhr.responseText)
994 }
995 }
996 }
997 xhr.send(JSON.stringify(issueData))
998 }
999})()

Callers 1

showMarkdownModalFunction · 0.85

Calls 1

showDialogFunction · 0.70

Tested by

no test coverage detected