Hack #30. Show Hidden Form Fields
See what hidden information you're submitting to a site.
One of the features of HTML forms is the ability to include hidden form fields. If you view source on a page, you can see them, tucked away next to the visible form fields. Their presence can be completely innocuous, perhaps storing your previous input in a multipage progression of complex forms. They can also hold tracking information that the site developer uses to track your movements throughout the site. Whatever their purpose, it can be difficult to wade through the page source to see what the site is hiding from you.
This hack makes hidden form fields visible. And, as an added bonus, it makes them editable as well.
The Code
This user script runs on all pages. Most of the work is done by a single XPath query, which finds <input type="hidden"> elements. Then it's a simple matter of iterating through the <input> elements and changing them to <input type="text">, which makes them simultaneously visible and editable in one fell swoop.
Save the following user script as unhideforms.user.js:
// ==UserScript== // @name Display Hidden Form Fields // @namespace http://diveintomark.org/projects/greasemonkey/ // @description un-hide hidden form fields and make them editable // @include * // ==/UserScript== var snapHidden = document.evaluate("//input[@type='hidden']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); for (var i = snapHidden.snapshotLength - 1; i >= 0; i--) { var elmHidden ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access