Skip to content

Instantly share code, notes, and snippets.

@rtucker-mozilla
Created February 10, 2020 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtucker-mozilla/adefbacbf0849e6727075de6f2694cc0 to your computer and use it in GitHub Desktop.
Save rtucker-mozilla/adefbacbf0849e6727075de6f2694cc0 to your computer and use it in GitHub Desktop.
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