ServiceNow - Nav Header additional functions

Add functions to Nav Header

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         ServiceNow - Nav Header additional functions
// @version      0.0.6
// @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;
    }

    if(typeof g_form == 'undefined') {
        return;
    }

    let tableName = window.location.pathname.match(/\/(\w*)\.do/).pop();
    let recordId = g_form.getUniqueValue();
    
    let listButton = document.createElement('a');
    listButton.title = '[WK - SN] Open List';
    listButton.href = '/' + tableName + '_list.do';
    listButton.classList.add('btn', 'btn-icon', 'navbar-btn', 'icon', 'icon-list');

    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.classList.add('btn', 'btn-icon', 'navbar-btn', 'icon', 'icon-new-ticket');
    copySysIdButton.addEventListener('click', () => copyToClipboard(recordId));

    let historyListButton = document.createElement('a');
    historyListButton.title = '[WK - SN] Open History List';
    historyListButton.classList.add('btn', 'btn-icon', 'navbar-btn', 'icon', 'icon-book-open');
    historyListButton.addEventListener('click', () => showHistoryList());
    
    let xmlViewButton = document.createElement('a');
    xmlViewButton.title = '[WK - SN] Open XML View';
    xmlViewButton.classList.add('btn', 'btn-icon', 'navbar-btn', 'icon', 'icon-form');
    xmlViewButton.addEventListener('click', () => xmlView(tableName, recordId));

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

})();