I'm currently pulling last names out of a document and copying them to clipboard in a userscript using...
var txt = $('p.overview.text').text();
var lastName = txt.match(/Last Name: (.*)/)[1].split("First Name: ", 1);
GM_setClipboard(lastName);
But I want to test the lastName against an array to make sure it's not any of these "I", "II", "III", "IV" etc. Because the system that is giving me the document and last name within sometimes screws up and gives me the roman numeral (instead of the last name) if the person has one (ie Jerry Louis VI = "VI" instead of "Louis").
What I've tried just to test this first before running it is on the actual documents
var txt = $('p.overview.text').text();
var lastName = txt.match(/Last Name: (.*)/)[1].split("First Name: ", 1);
var lastNameVal = lastName[0]; // This is the correct variable for actual use
lastNameVal = "I"; // This is how I am testing it, will delete when done with testing
if (lastNameVal.text !== "I") {
GM_setClipboard(lastNameVal);
}
The above works in that it detects that the variables value as "I" after assigning it. But obviously I need to test this against an array of roman numerals, probably going up to XII or so. I've tried creating an array within the if statement using || (or) operator to test against like so...
if (lastNameVal !== "I" || "II" || "III") {
GM_setClipboard(lastNameVal);
}
But that is not working... What would be the best way to accomplish this? Thanks
Aucun commentaire:
Enregistrer un commentaire