These are the steps that I recommend for creating bookmarklets:
1. Put everything in a function called immediately
You can use (function(){YOUR CODE}());or(function(){YOUR CODE})();
2. Collapse your code
You can use the online javascript script
3. URL-encode it
You can use an online encoder
In your case, it might be something like this:
(function(){m=document.getElementById('xxx');m.value=17}());
encoded as:
(function()%7Bm%3Ddocument.getElementById('xxx')%3Bm.value%3D17%7D())%3B
See DEMO .
source
share