NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Jira ready for review message // @description Lets you copy a message ready for pasting into Slack when a story is ready for review or prioritisation // @namespace https://openuserjs.org/users/floodmeadows // @copyright 2021, floodmeadows (https://openuserjs.org/users/floodmeadows) // @license MIT // @version 0.1.4 // @include https://jira.*.uk/browse/* // @updateURL https://openuserjs.org/meta/floodmeadows/Jira_ready_for_review_message.meta.js // @downloadURL https://openuserjs.org/src/scripts/floodmeadows/Jira_ready_for_review_message.user.js // @grant none // ==/UserScript== const currentUrl = new URL(document.URL); const jiraBaseUrl = currentUrl.protocol + '//' + currentUrl.host; const slackEmojiForLgtm = ":lgtm:"; (function() { 'use strict'; addReadyForReviewMessage(); addReadyForProiritisationMessage(); addCopyReadyForReviewMessageButton(); addCopyReadyForPrioritisationMessageButton(); })(); function addReadyForReviewMessage() { const issueKey = document.getElementById("key-val").childNodes[0].nodeValue; const issueName = document.getElementById("summary-val").childNodes[0].nodeValue; const newElement = document.createElement("textarea"); newElement.setAttribute("id", "story-ready-for-review-message"); newElement.setAttribute("style", "width:1px; height:1px; display:inline; float:right; position:relative; left:300px; top:0;"); var h = "Story ready for review:\r\n"; h += issueName + "\r\n"; h += "(" + jiraBaseUrl + "/browse/" + issueKey + ")\r\n"; h += "\r\n"; h += "If you have comments or questions, please start a thread >>>\r\n"; h += "If it's ready for dev, let me know with a " + slackEmojiForLgtm + " . Thanks."; newElement.innerHTML = h; const target = document.getElementById('summary-val'); target.parentNode.appendChild(newElement); } function addReadyForProiritisationMessage() { const issueKey = document.getElementById("key-val").childNodes[0].nodeValue; const issueName = document.getElementById("summary-val").childNodes[0].nodeValue; const newElement = document.createElement("textarea"); newElement.setAttribute("id", "story-ready-for-prioritisation-message"); newElement.setAttribute("style", "width:1px; height:1px; display:inline; float:right; position:relative; left:300px; top:0;"); var h = "This is now ready for review:\r\n"; h += issueName + "\r\n"; h += "(" + jiraBaseUrl + "/browse/" + issueKey + ")\r\n"; newElement.innerHTML = h; const target = document.getElementById('summary-val'); target.parentNode.appendChild(newElement); } function addCopyReadyForReviewMessageButton() { const newElement = document.createElement("a"); newElement.setAttribute("href","#"); newElement.setAttribute("id","btn-copy-ready-for-review-message"); newElement.setAttribute("class","aui-button toolbar-trigger issueaction-workflow-transition"); newElement.addEventListener("click", copyReadyForReviewMessage); const text = document.createTextNode("Copy 'Ready for review' message"); newElement.appendChild(text); const target = document.getElementById('opsbar-transitions_more'); target.parentNode.appendChild(newElement); } function addCopyReadyForPrioritisationMessageButton() { const newElement = document.createElement("a"); newElement.setAttribute("href","#"); newElement.setAttribute("id","btn-copy-ready-for-review-message"); newElement.setAttribute("class","aui-button toolbar-trigger issueaction-workflow-transition"); newElement.addEventListener("click", copyReadyForPrioritisationMessage); const text = document.createTextNode("Copy 'Ready for Prioritisation' message"); newElement.appendChild(text); const target = document.getElementById('opsbar-transitions_more'); target.parentNode.appendChild(newElement); } function copyReadyForReviewMessage() { var copyText = document.getElementById("story-ready-for-review-message"); copyText.select(); copyText.setSelectionRange(0, 99999); /* For mobile devices */ document.execCommand("copy"); } function copyReadyForPrioritisationMessage() { var copyText = document.getElementById("story-ready-for-prioritisation-message"); copyText.select(); copyText.setSelectionRange(0, 99999); /* For mobile devices */ document.execCommand("copy"); }