Skip to content

Instantly share code, notes, and snippets.

@jacobroufa
Last active October 9, 2015 21:42
Show Gist options
  • Select an option

  • Save jacobroufa/4e3442f226fec32917dc to your computer and use it in GitHub Desktop.

Select an option

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.
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)}();})();
(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' );
}
})();
@jacobroufa

Copy link
Copy Markdown
Author

To use, copy the editReadOnlyInputs.bookmarklet.js content into a new bookmark. On the page you would like to edit input fields with a readonly attribute 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment