Last active
March 6, 2018 14:34
-
-
Save oieioi/bbc040f4d8a2c8116ed526580a54dfc5 to your computer and use it in GitHub Desktop.
GitHub の issue 作成画面のテンプレートを作る
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
// ==UserScript== | |
// @name GitHub issue templatize | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2 | |
// @description GitHub issue templatize | |
// @author oieioi | |
// @match https://github.com/*/*/issues/new* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const locateTemplitized = function(){ | |
const title = encodeURIComponent(document.querySelector('#issue_title').value); | |
const body = encodeURIComponent(document.querySelector('#issue_body').value); | |
const labels = [].map.call(document.querySelectorAll('.labels a'), (e)=> encodeURIComponent(e.innerText)).join(','); | |
const url = `${location.origin}${location.pathname}?title=${title}&body=${body}&labels=${labels}`; | |
location.href= url; | |
}; | |
//<a href="#" class="btn btn-sm">2md</a> | |
const button = document.createElement('a'); | |
button.classList = "btn"; | |
button.innerText = "Templatize"; | |
// button.href = "btn btn-sm"; | |
button.addEventListener('click', locateTemplitized); | |
document.querySelector('.form-actions').append(button); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment