Created
August 25, 2023 20:42
-
-
Save reflexdemon/6a8b69c754ad5d4036df1ca1333d84b8 to your computer and use it in GitHub Desktop.
This is a GreeseMonkey script for enabling commit messages
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 Copy Commit Message | |
// @version 1 | |
// @include https://jira* | |
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js | |
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js | |
// @grant GM_setClipboard | |
// @grant GM_addStyle | |
// ==/UserScript== | |
if ($('#ghx-header').length) { | |
waitForKeyElements ('.ghx-selected', issueLinkFound); // FOR SPRINT BOARD | |
} else { | |
waitForKeyElements ('#summary-val', issueLinkFound); // FOR FULL PAGE VIEW | |
} | |
function issueLinkFound(jNode) { | |
console.log('Greese Monkey is active!!!') | |
var summary = $('#summary-val'); | |
console.log('Commit Message: summary = ', summary.text()); | |
var issueKey = $('#issuekey-val').length?$('#issuekey-val').text(): $('#key-val').attr('data-issue-key'); | |
console.log('Commit Message: issueKey = ', issueKey); | |
var content = `${issueKey}: ${summary.text()}`; | |
console.log(`Commit Message: ${content} ready to be copied`); | |
var htmlContent = ` | |
<div class="wrap" id="do-not-insert"> | |
<strong class="name" title="Commit Message"> | |
<label for="commit-message">Commit Message:</label> | |
</strong> | |
<span id="commit-message" class="twixi-block expanded flooded" title="${content}"><div style="background: #f0f0f0; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;"><pre style="margin: 0; line-height: 125%; width:100%">${content}</pre></div></span> | |
</div> | |
`; | |
// var htmlContent = ` | |
// <style type="text/css"> | |
// .terminal { | |
// position: relative; | |
// width: 80%; | |
// max-width: 600px; | |
// border-radius: 6px; | |
// padding-top: 45px; | |
// margin-top: 8px; | |
// overflow: hidden; | |
// background-color: rgb(15, 15, 16); | |
// } | |
// .terminal::before { | |
// content: "\2022 \2022 \2022"; | |
// position: absolute; | |
// top: 0; | |
// left: 0; | |
// height: 4px; | |
// background: rgb(58, 58, 58); | |
// color: #c2c3c4; | |
// width: 100%; | |
// font-size: 2rem; | |
// line-height: 0; | |
// padding: 14px 0; | |
// text-indent: 4px; | |
// } | |
// .terminal pre { | |
// font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace; | |
// color: white; | |
// padding: 0 1rem 1rem; | |
// margin: 0; | |
// } | |
// </style> | |
// <div class="wrap" id="do-not-insert"> | |
// <strong class="name" title="Commit Message"> | |
// <span class="twixi-block expanded flooded terminal"> | |
// <pre>${content}</pre> | |
// </strong> | |
// </span> | |
// </div> | |
// `; | |
console.log('htmlContent = ', htmlContent); | |
if ($('#do-not-insert').length) { | |
// Element already exist | |
} else { | |
if ($('#details-module-label').length) { | |
$('#details-module-label').after(htmlContent); | |
} | |
} | |
// if ($('#details-module_heading').length) $('#details-module_heading').after(htmlContent); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment