Skip to content

Instantly share code, notes, and snippets.

@rymndhng
Last active April 27, 2021 22:38
Show Gist options
  • Save rymndhng/13ac783007c3912dfd00c35bb3e8eeb3 to your computer and use it in GitHub Desktop.
Save rymndhng/13ac783007c3912dfd00c35bb3e8eeb3 to your computer and use it in GitHub Desktop.
JIRA Issue Bookmarklet
javascript:(function() {
"support old jira first";
const descriptionElement = document.getElementById("description");
if (descriptionElement) {
descriptionElement.value = "*What*:\n\n*Why*:\n\n*What does success look like?*\n\n*Testing Notes*\n\n*Technical Notes/Hints*\n\n";
return;
}
"support new jira issue view";
const proseMirrorElement = document.getElementsByClassName("ProseMirror")[0];
if (proseMirrorElement) {
const evt = new ClipboardEvent("paste");
evt.clipboardData.items.add("**What**: *The thing we're trying to do*\n\n**Why**: *what's the rationale for doing this? What is the motivating reason for this work?* \n\n**What does success look like?**\n- *What are all the technical items we need to address*\n\n**Testing Notes**\n- *What are the steps a tester needs to do to verify this change?*\n\n**Technical Notes/Hints**\n- *What contextual information would help drive the implementation?*\n\n", "text/plain");
proseMirrorElement.dispatchEvent(evt);
return;
}
alert("Unable to find a JIRA Issue Description on this page!");
})();
@ds-clearago
Copy link

Now that JIRA phased out the old issue view, I was trying this on Jira Cloud new issue view on 25.04.2021 with Chrome Version 90.0.4430.85 on Mac OS 10.15.7 but I can't seem to be able to add the ClipboardEvent.

const evt = new ClipboardEvent("paste")
evt.clipboardData.items.add("**Wh")
--> Uncaught TypeError: Cannot read property 'items' of null

I can't figure this out even after reading https://www.w3.org/TR/clipboard-apis/

Previously, I already had changed
$(".ProseMirror") from your script to document.getElementsByClassName("ProseMirror") as I was getting Uncaught ReferenceError: $ is not defined... Do you know what might be wrong? Cheers, Dennis

@rymndhng
Copy link
Author

Hey, glad you found use for the script -- I don't actively use this script anymore. I also don't use Chrome, so I don't know what the quirks are across browsers. The script seems to work fine in Firefox.

I used this source as a reference to this script.

Good luck!

@rymndhng
Copy link
Author

@ds-clearago -- I gave the script a try today on Firefox and it still works. The issue you're encountering might be Chrome specific

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment