Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
greasemonkey script to make it easier to fill in HP Warranty Serial Numbers
// ==UserScript==
// @name Check HP Warranty Data
// @version 1
// @grant none
// ==/UserScript==
//configure script include to run at https://support.hpe.com/hpsc/wc/public/find
var x = document.createElement("TEXTAREA");
var b = document.createElement("BUTTON");
b.innerHTML = "Fill fields";
x.rows = 20;
x.cols = 100;
b.addEventListener ("click", function(e){
var data = x.value;
var dataList = data.split("\n");
var counter = 0;
var maxCounter = 20;
dataList.forEach(function(e){
if(counter == maxCounter){
alert("Exceeded Maximum Inputs. Next serial to paste is: " + e);
counter++
} else {
var idString = "serialNumber" + counter;
document.getElementById(idString).value = e;
counter++;
}
});
});
document.body.appendChild(x);
document.body.appendChild(b);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment