MyFirstUserScript_Aaron

testing SNOW

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         MyFirstUserScript_Aaron
// @namespace    AaronLong
// @version      1.5
// @description  testing SNOW
// @author       AaronLong
// @match        https://sap.service-now.com/*
// @match        https://test.itsm.services.sap/*
// @match        https://itsm.services.sap/*
// @icon         https://www.google.com/s2/favicons?domain=services.sap
// ==/UserScript==

 (function() {
     'use strict';
 
 function addButton(text, onclickAtt,clickFuncContent,cssObj) {
     cssObj = cssObj || {fontWeight: '600', fontSize: '14px', backgroundColor: '#00cccc', color: 'white', border: 'none', padding: '10px 20px', };
     let div = document.createElement('div');
     let button = document.createElement('button'), btnStyle = button.style	; 
     let click_att = document.createAttribute("onclick");       // Create a "class" attribute
     click_att.value = onclickAtt;
     button.setAttributeNode(click_att);                      
     button.innerHTML = text;
     Object.keys(cssObj).forEach(key => btnStyle[key] = cssObj[key]);
     let scriptlet = document.createElement('Script');
     let src_code = document.createTextNode(clickFuncContent);
     scriptlet.appendChild(src_code);
     document.body.appendChild(div).appendChild(button);
     document.body.appendChild(scriptlet);
     return button;
 }
 
var onclick_testFunction ="function onclick_testFunction(){alert('Testing click!!!');return false;}";
var setUpdateTime ="function setUpdateTime(col_idx){var caseTab = document.getElementById('sn_customerservice_case_table');	var tbl=caseTab.getElementsByTagName('tbody')[0];	var trs=tbl.getElementsByTagName('tr');	for(j =1; j<trs.length; j++){	/*alert(trs[j].innerHTML);console.log(trs[j].innerHTML);*/ console.log(trs[j].getElementsByTagName('td').length);	txtValue = trs[j].getElementsByTagName('td')[col_idx].innerHTML; console.log('txtValue='+txtValue);		if(txtValue.length>=19){trs[j].getElementsByTagName('td')[col_idx].innerHTML=txtValue.substr(0,19);}	}	return;}";
var calBtn = addButton('CalcProcessingTime','onclick_testFunction()',onclick_testFunction,);
var updateTimeBTN = addButton('UpdateTime','setUpdateTime(30)',setUpdateTime,); 
 })();