rubenmartinez / Confluence Links

// ==UserScript==
// @name         Confluence Links
// @namespace    http://rubenmartinez.net/
// @version      0.1
// @description  Just add most used links to the top
// @author       Ruben Martinez
// @match        https://buongiorno.atlassian.net/wiki/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var placeHolder = $("#people-directory-link").parent().parent();

    var links = [
        { url: "/wiki/display/PPSU/LMN+Weekly+Meeting", text: "LMN Meetings", key:"m" },
        { url: "/wiki/display/PPSU//LMN+Countries+Implementation", text: "LMN Countries", key:"c" },
        { url: "/wiki/users/viewmydrafts.action", text: "Drafts", key:"d" },
        { url: "/wiki/users/viewmyfavourites.action", text: "Starred", key:"s" },
        { url: "/wiki/plugins/inlinetasks/mytasks.action", text: "Tasks", key:"t" }
        //{ url: "/wiki/display/PPSU/Big+Data", text: "PSU Big Data" }
    ];

    function getHtmlListItemLink(url, text, key) {
        let id = "custom-link-" + text.replace(/ /g, '_');
        return `<li><a id="${id}" href="${url}" class=" aui-nav-imagelink" title="${text}" accesskey="${key}"><span>${text}</span></a></li>`;
    }
    function appendLinkToTopBar(html) {
        //$(html).hide().appendTo(placeHolder).fadeIn(3000);
        $(html).appendTo(placeHolder);
    }

    window.addEventListener('load', function() {
        for (let link of links) {
            appendLinkToTopBar(getHtmlListItemLink(link.url, link.text, link.key));
        }
    }, false);
})();