Created
April 2, 2017 13:14
-
-
Save itkq/c04ec687647f4e17354096a6fbedfc47 to your computer and use it in GitHub Desktop.
Alfred Vivaldi workflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?