Skip to content

Instantly share code, notes, and snippets.

@itkq
Created April 2, 2017 13:14
Show Gist options
  • Save itkq/c04ec687647f4e17354096a6fbedfc47 to your computer and use it in GitHub Desktop.
Save itkq/c04ec687647f4e17354096a6fbedfc47 to your computer and use it in GitHub Desktop.
Alfred Vivaldi workflow
require 'digest/md5'
script = <<-SCRIPT
var list = new Array();
Application("Vivaldi").windows().forEach(function(window){
window.tabs().forEach(function(tab){
list.push(tab.name() + "\t" + tab.url());
});
});
list.join("\\n")
SCRIPT
output = `osascript -l JavaScript -e '#{script}'`
items = ''
output.split("\n").select{|l| l.include?(ARGV[0] || '')}.each do |line|
name, url = line.split("\t")
items << <<-EOH
<item uid="#{Digest::MD5.hexdigest(url)}" valid="yes">
<title>#{name.encode(xml: :text)}</title>
<subtitle>#{url.encode(xml: :text)}</subtitle>
<icon>icon.png</icon>
</item>
EOH
end
puts <<EOH
<?xml version="1.0"?>
<items>
#{items}
</items>
EOH
@DuckJsus
Copy link

Good afternoon. Tell me, this script is somehow related to the creation of workspaces in the Vivaldi browser? I'm looking for an analog of workspaces from Opera. Maybe this can help?

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