Not my code, but I will try to help you. Normally the new tab is controlled by the target
attribute. _blank
means to open the link in a new tab:
https://wiki.selfhtml.org/wiki/HTML/Attribute/target
Here is a modified version (untested) which provides a local
attribute to control it:
// Change these fields to whatever urls you want to link to in your sidebar, the id attribute should be unique for the entire page
var links = [
{ id: 'custom-link-1', name: 'Example Link 1', icon: 'icon-chain', url: 'https://www.example.com', permission: 'ticket.agent' },
{ id: 'custom-link-2', name: 'Example Link 2', icon: 'icon-cloud', url: 'https://www.zammad.com', permission: 'ticket.agent' },
{ id: 'custom-link-3', name: 'Example Link 3', icon: 'icon-external', url: 'https://www.zammad.org' },
{ id: 'custom-link-4', name: 'Example Link 4', icon: 'icon-external', url: '#ticket/zoom/124848', local: true },
];
// Failsafe in case things go wrong, generally it adds these links fine after just two detected mutations.
var failsafecount = 0;
function check(changes, observer) {
if (failsafecount > 999) return;
var navMenu = $("#navigation > .menu.js-menu");
if (!navMenu.length) return;
links.forEach(function(link) {
if ((!link.permission || App.User.current && App.User.current().permission(link.permission)) && !$('#' + link.id).length) {
++failsafecount;
navMenu.append (
'<a class="menu-item" href="' + link.url + '"' + (link.local ? '' : ' target="_blank"') + ' id="' + link.id + '"><svg class="icon icon-lock menu-item-icon"><use xlink:href="assets/images/icons.svg#' + link.icon + '"></use></svg><span class="menu-item-name">' + link.name + '</span></a>'
);
}
});
}
new MutationObserver(check).observe(document, {childList: true, subtree: true});