Skip to content

Instantly share code, notes, and snippets.

@jwcobb
Last active December 14, 2015 06:29
Show Gist options
  • Save jwcobb/5043199 to your computer and use it in GitHub Desktop.
Save jwcobb/5043199 to your computer and use it in GitHub Desktop.
Removes unwanted spaces from barcode input fields on EventInventory.com
// ==UserScript==
// @name EI Barcode De-Spacer
// @namespace TeamOneTickets
// @include https://www.eventinventory.com//Basic/AirBillManager/Barcode.aspx*
// @description Removes unwanted spaces from barcode input fields because EI doesn't know how to RegEx
// @copyright Team One Tickets & Sports Tours, Inc.
// @version 1.0
// @license BSD
// ==/UserScript==
// Install this into Chrome using Tampermonkey (https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo)
// Shoudl also work with Greasemonkey on FireFix (not tested)
function strip(e) {
e.value = e.value.replace(/[\n\t]*/g,"").replace(/[ ]+/g,"");
}
var boxes = document.evaluate("//input[@type='text']",document,null,6,null);
for(var i=boxes.snapshotLength-1; (item=boxes.snapshotItem(i)); i--) {
item.addEventListener('blur', function(e){strip(e.currentTarget);}, false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment