Last active
October 9, 2015 21:42
-
-
Save jacobroufa/4e3442f226fec32917dc to your computer and use it in GitHub Desktop.
This is a bookmarklet for editing the value of inputs marked with the readonly attribute.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| javascript:(function(){!function(){"use strict";function a(a){return a.attributes.readonly}function b(a){a.addEventListener("click",c)}function c(a){a.target.value=prompt("enter new value")}var d=document.getElementsByTagName("input"),e=Array.prototype.slice.call(d),f=e.filter(a);f.forEach(b)}();})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function(){ | |
| 'use strict'; | |
| var inputs = document.getElementsByTagName('input') | |
| var arrInputs = Array.prototype.slice.call( inputs ); | |
| var filteredInputs = arrInputs.filter( getReadOnly ); | |
| filteredInputs.forEach( assignEventHandler ); | |
| function getReadOnly( input ) { | |
| return input.attributes.readonly; | |
| } | |
| function assignEventHandler( input ) { | |
| input.addEventListener( 'click', getNewValue ); | |
| } | |
| function getNewValue( e ) { | |
| e.target.value = prompt( 'enter new value' ); | |
| } | |
| })(); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use, copy the
editReadOnlyInputs.bookmarklet.jscontent into a new bookmark. On the page you would like to edit input fields with areadonlyattribute set, just click the bookmark and then click on the field and you will be presented with a prompt for the value you would like to set.