Skip to content

Instantly share code, notes, and snippets.

@mintuhouse
Last active May 7, 2020 18:38
Show Gist options
  • Save mintuhouse/688f62ca583736cbec8622eedf93fbfd to your computer and use it in GitHub Desktop.
Save mintuhouse/688f62ca583736cbec8622eedf93fbfd to your computer and use it in GitHub Desktop.
Add empty file
// ==UserScript==
// @name GitHub PR Add Merge Description
// @version 1.0.0
// @description A userscript that adds merge commit description
// @license MIT
// @author Hasan Kumar
// @namespace https://github.com/mintuhouse
// @include https://github.com/*
// @run-at document-idle
// @grant none
// @icon https://github.githubassets.com/pinned-octocat.svg
// @updateURL https://gist.github.com/mintuhouse/688f62ca583736cbec8622eedf93fbfd/raw/githubMergeDescription.user.js
// @downloadURL https://gist.github.com/mintuhouse/688f62ca583736cbec8622eedf93fbfd/raw/githubMergeDescription.user.js
// ==/UserScript==
(() => {
"use strict";
function addDescription(){
const prDescription = $('.timeline-comment .js-comment-field').value;
const mergeDescElement = $('#merge_message_field');
mergeDescElement.value = prDescription;
mergeDescElement.style.height = mergeDescElement.scrollHeight + 'px';
}
function addDescriptionEvent() {
$("body").addEventListener("click", event => {
const target = event.target;
if (target && target.classList.contains("btn-group-merge")) {
setTimeout(addDescription, 0);
}
});
}
function $(str, el) {
return (el || document).querySelector(str);
}
addDescriptionEvent();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment