// ==UserScript== // @name jira-issue-navigate // @version 0.3.0 // @description Go to the next issue using a button // @author Amin Yahyaabadi // @match https://*.atlassian.net/browse/* // @match https://*.atlassian.net/jira/software/projects/* // @grant none // @license MIT // @namespace AminYa // @downloadURL none // ==/UserScript== function $1994abed16d377af$var$main() { const currentURL = window.location.href; // parse the URL const urlMatch = /(.*)\.atlassian\.net\/(browse|jira\/software\/projects)\/(.*)-(\d*)(\?.*)?/; const res = urlMatch.exec(currentURL); // if the url doesn't match return if (res === null) return; const [, company, middle, project, issue, queries] = res; const issueNumber = parseInt(issue, 10); // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition const queriesString = queries === undefined ? "" : queries; // create a button to go to the next issue const nextButton = document.createElement("button"); nextButton.id = "next-issue-btn"; nextButton.setAttribute("aria-label", "Go to next issue"); nextButton.setAttribute("aria-expanded", "false"); nextButton.setAttribute("aria-haspopup", "true"); nextButton.setAttribute("type", "button"); nextButton.style.borderRadius = "2px"; const buttonIcon = document.createElement("div"); buttonIcon.innerHTML = ` `; nextButton.style.background = "none"; nextButton.style.border = "none"; // attach the icon nextButton.appendChild(buttonIcon); // create a tooltip for the button that shows "Go to next issue" on hover const buttonTooltip = document.createElement("div"); buttonTooltip.id = "next-issue-btn-tooltip"; buttonTooltip.setAttribute("style", `position: relative;`); nextButton.prepend(buttonTooltip); const buttonTooltipText = document.createElement("div"); buttonTooltipText.innerHTML = "Next"; buttonTooltipText.setAttribute("style", `width: 50px; text-align: center; border-radius: 4px; padding: 1px 0; font-size: small; background: #172B4D; color: white; position: absolute; z-index: 1; bottom: 100%; left: 50%; margin-left: -30px; margin-bottom: 15px; `); buttonTooltipText.style.visibility = "hidden"; buttonTooltip.prepend(buttonTooltipText); // set the the button class const likeButtonSelector = "#jira-issue-header-actions > div > div > div:nth-child(4)"; const likeButton = document.querySelector(likeButtonSelector); if (likeButton !== null) { console.debug(`${likeButtonSelector} was not found`); nextButton.className = likeButton.className; } // button functionality nextButton.addEventListener("click", ()=>{ // get the next issue number const nextIssueNumber = issueNumber + 1; // create the next issue url const nextIssueURL = `${company}.atlassian.net/${middle}/${project}-${nextIssueNumber}${queriesString}`; // navigate to the next issue window.location.href = nextIssueURL; }); nextButton.addEventListener("mouseover", ()=>{ nextButton.style.background = "#091e4214"; buttonTooltipText.style.visibility = "visible"; }); nextButton.addEventListener("mouseleave", ()=>{ nextButton.style.background = "none"; buttonTooltipText.style.visibility = "hidden"; }); // attach the button to the toolbar const toolbarSelector = "#jira-issue-header-actions > div > div"; const toolbar = document.querySelector(toolbarSelector); if (toolbar === null) { console.debug(`${toolbarSelector} was not found`); return; } toolbar.prepend(nextButton); } setTimeout($1994abed16d377af$var$main, 2000); //# sourceMappingURL=main.js.map