To be clear, by “injecting JavaScript” I mean the official way supported by Data Center plugin framework.
In atlassian-plugin.xml, add your JavaScript:
<atlassian-plugin key="${atlassian.plugin.key}" name="${project.name}" plugins-version="2">
<!-- Do not reuse name attributes here. All of them are considered a module in this plugin -->
<plugin-info>
<description>${project.description}</description>
<version>${project.version}</version>
<vendor name="${project.organization.name}" url="${project.organization.url}" />
</plugin-info>
<resource type="i18n" name="i18n" location="CustomFieldTypes"/>
<!-- Web resources like CSS and JS -->
<web-resource key="resources" name="Jira Resources">
<!-- Since Jira 5.0, edit screen no longer supports $webResourceManager.requireResource. We need to put resources in specific context instead. -->
<context>atl.general</context> <!-- General context -->
<context>atl.admin</context> <!-- Admin context, i.e. custom field configuration pages -->
<context>customerportal</context> <!-- Customer portal, i.e. service management pages -->
<context>servicedesk.general</context> <!-- Service Desk general -->
<context>servicedesk.admin</context> <!-- Sercice Desk admin -->
<!-- This is your script to do the magic -->
<resource type="download" name="CustomFieldTypes.js" location="/js/CustomFieldTypes.js"/>
</web-resource>
You need to specify all the contexts where you want your script to be available.
Then in your script, you try to find your specific link, and if found, add the target attribute to it.
function myMagicFunc() {
// Setup MutationObserver to find target link and modify it
}
AJS.toInit(myMagicFunc());