Hacker News new | ask | show | jobs
by thristian 5395 days ago
Thanks for that!

I had to make some changes to get it working on my machine:

  javascript:(function() {var d=document;var t=d.getElementsByTagName('textarea');for(var i in t){if(typeof t[i]=='object') t[i].setAttribute('class','webvi');}var s=d.createElement('script');s.async=false;s.setAttribute('src','http://webvi.googlecode.com/svn/trunk/lib/webvi.js');d.body.appendChild(s);webvi_init();})();
In particular, you missed a ' in the .setAttribute() call, and I had to set .async=false on the script element so that it would load and execute it before trying to call webvi_init().

EDIT: No, that doesn't work either. It runs in Firebug if I paste it into the console and remove the "javascript:" prefix, but it doesn't run as a bookmarklet: it just complains about webvi_init() not being defined, even though the async flag is cleared. :(((

1 comments

I got it working on Chrome by executing webvi_init() on s.onload():

  javascript:(function(){var d=document;var t=d.getElementsByTagName('textarea');for(var i in t){if(typeof t[i]=='object') t[i].setAttribute('class','webvi');} var s=d.createElement('script');s.setAttribute('src','http://webvi.googlecode.com/svn/trunk/lib/webvi.js');d.body.appendChild(s);s.onload=function(){webvi_init();};})();
That got it working, thanks!

Then I tried to write a comment in HN using WebVi in the reply box, and after I hit 'Submit', the comment that actually got posted was just 'M' instead of what I (thought I) wrote. Ah well, early days yet. :)