require 'tmpdir' require 'fileutils' require 'pp' $tmp_dir = 'idk' $pid = 0 class Chrome def initialize @chrome_path = '"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"' @opts = "--incognito --user-data-dir=#{$tmp_dir} " end def run $tmp_dir = Dir.mktmpdir ARGV.each { |e| @opts << " --new-window #{e}" } Process.wait($pid = spawn([@chrome_path, @opts].join(' '))) end def delet if $tmp_dir != "idk" FileUtils.remove_dir($tmp_dir, :force => true) puts "[Attempt to remove: #{$tmp_dir}]" end end end @chr = Chrome.new at_exit do if File.directory?($tmp_dir) @chr.delet end end if ARGV.size > 0 @chr.run else puts "Usage: #{$0} [url1, url2, ...]" end