ServiceNow - Nav Header additional functions

Add functions to Nav Header

Stan na 02-02-2024. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         ServiceNow - Nav Header additional functions
// @version      0.0.1
// @description  Add functions to Nav Header
// @author       Matteo Lecca
// @match        *.service-now.com/*.do*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=service-now.com
// @grant        none
// @license MIT
// @namespace    https://greasyfork.org/users/1246673
// ==/UserScript==

(function() {
    'use strict';

    let navHeader = document.querySelector('.navbar-header');

    if(!navHeader) {
        return;
    }

    let tableName = window.location.pathname.match(/\/(\w*)\.do/).pop();
    let recordId = g_form.getUniqueValue();

    let versionsButton = document.createElement('a');
    versionsButton.title = '[WK - SN] Open Versions';
    versionsButton.href = '/sys_update_version_list.do?sysparm_query=name=' + tableName + '_' + recordId;
    versionsButton.classList.add('btn', 'btn-icon', 'navbar-btn', 'icon', 'icon-folder');

    let copySysIdButton = document.createElement('a');
    copySysIdButton.title = '[WK - SN] Copy sys_id';
    copySysIdButton.onclick = copySysId;
    copySysIdButton.classList.add('btn', 'btn-icon', 'navbar-btn', 'icon', 'icon-new-ticket');

    let historyListButton = document.createElement('a');
    historyListButton.title = '[WK - SN] Open History List';
    historyListButton.onclick = openHistoryList;
    historyListButton.classList.add('btn', 'btn-icon', 'navbar-btn', 'icon', 'icon-book-open');

    navHeader.append(versionsButton);
    navHeader.append(copySysIdButton);
    navHeader.append(historyListButton);

    function copySysId(evt) {
        copyToClipboard(g_form.getUniqueValue());
    }

    function openHistoryList(evt) {
        showHistoryList();
    }

})();