Highlight my incidents/changes
当前为
// ==UserScript==
// @name Highlight Assigned to Me
// @version 0.1
// @description Highlight my incidents/changes
// @author Ricardo Constantino
// @match https://frusupport.service-now.com/*_list.do?*
// @grant none
// @namespace https://greasyfork.org/users/129739
// ==/UserScript==
(function() {
'use strict';
const ALLOWED_TABLES = ['change_request', 'incident'];
const BG_COLOR = '#bcefff';
const EVEN_STYLE = `
background-color: ${BG_COLOR} !important;
`;
const ODD_STYLE = `
/* background-color: ${BG_COLOR}87 !important; */
${EVEN_STYLE}
`;
let assignedToColumn = document.querySelector('th[name="assigned_to"]');
if (!assignedToColumn) return;
let assignedToColumnIdx = [...assignedToColumn.parentElement.children].indexOf(assignedToColumn);
let tableElem = assignedToColumn.parentElement.parentElement.parentElement;
if (ALLOWED_TABLES.length > 1 && ALLOWED_TABLES.indexOf(assignedToColumn.parentElement.parentElement.parentElement.getAttribute('list_name')) === -1) return;
let rowsAssignedToMe = [...tableElem.querySelectorAll('td:nth-child('+(assignedToColumnIdx+1)+')')]
.filter(e => e.children.length > 0 && e.children[0].getAttribute('sys_id') === g_user.getUserID());
rowsAssignedToMe.forEach(r => r.parentElement.addClassName('assignedToMe'));
let d = document.createElement('style');
d.textContent = `tr.assignedToMe.list_even td { ${EVEN_STYLE} }\ntr.assignedToMe.list_odd td { ${ODD_STYLE} }`;
document.querySelector("style").append(d);
})();