phantomjs でアンカーへ移動した状態でスクリーンショットを保存したかった
phantomjs で
https://github.com/osyo-manga/vim-textobj-multiblock/blob/master/plugin/textobj/multiblock.vim#L10
みたいにアンカーへ移動した状態でスクリーンショットを保存したかったんですが、そのまま開くだけでは移動しなかったので自前でクリッピングしました。
[ソース]
var url = "https://github.com/osyo-manga/vim-textobj-multiblock/blob/master/plugin/textobj/multiblock.vim#L10" var output = "output.png" var page = require('webpage').create(); page.open(url, function (status) { page.includeJs('http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js', function() { var anchor = page.evaluate(function() { var hash = location.hash; if( hash == "" ){ return 0 } return $(hash).offset().top; }); var width = page.evaluate(function() { return $(document).width(); }); var height = page.evaluate(function() { return $(document).height(); }); page.clipRect = { top: anchor, left: 0, width: width, height: height - anchor }; page.render(output); phantom.exit(); }); });