Skip to content

Instantly share code, notes, and snippets.

@marckohlbrugge
Created February 15, 2013 16:54
Show Gist options
  • Save marckohlbrugge/4961684 to your computer and use it in GitHub Desktop.
Save marckohlbrugge/4961684 to your computer and use it in GitHub Desktop.
Adds Shuffler.fm support to @Silouane20's 'Media' Alfred Extension ( http://silouane20.tumblr.com/post/16058261065/alfred-extension-for-music-websites ) I didn't edit the info.plist much, but I somehow must have messed up the indenting so the diff shows a lot of unchanged lines.
diff --git a/fave.js b/fave.js
new file mode 100644
index 0000000..0745838
--- /dev/null
+++ b/fave.js
@@ -0,0 +1,7 @@
+(function(){
+ switch(location.hostname){
+ case "shuffler.fm":
+ $('div#favorite')[0].click();
+ break;
+ }
+})();
\ No newline at end of file
diff --git a/info.plist b/info.plist
index a460840..4343880 100644
--- a/info.plist
+++ b/info.plist
@@ -1,33 +1,63 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>action</key>
- <false/>
- <key>background</key>
- <true/>
- <key>category</key>
- <string>APPLESCRIPTS</string>
- <key>command</key>
- <string>#Usage : Type media play/next/prev
-#Work with deezer and grooveshark. For more supported websites or bugs contact me @Silouane20 on twitter.
-#Assigning hotkeys to this extension improves it !
-
-on alfred_script(q)
- set unixpath to (do shell script "pwd") &amp; "/"
set unixpath to unixpath &amp; q &amp; ".js"
- set foo to (open for access (POSIX file unixpath))
set txt to (read foo for (get eof foo))
close access foo
tell application "System Events"
if exists (application process "Safari") then
tell application "Safari"
set W to every window
repeat with Wi in W
set T to every tab of Wi
repeat with Ti in T
tell Ti
do JavaScript txt
end tell
end repeat
end repeat
end tell
- end if
- if exists (application process "Google Chrome") then
tell application "Google Chrome"
set W to every window
repeat with Wi in W
set T to every tab of Wi
repeat with Ti in T
tell Ti
execute javascript txt
end tell
end repeat
end repeat
end tell
- end if
end tell
end alfred_script</string>
- <key>disabled</key>
- <false/>
- <key>keyword</key>
- <string>media</string>
- <key>parameter</key>
- <integer>2</integer>
- <key>subtitle</key>
- <string>Previous, play/pause, next track on music sites</string>
- <key>title</key>
- <string>Use media keys on music sites</string>
-</dict>
-</plist>
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>action</key>
+ <false/>
+ <key>background</key>
+ <true/>
+ <key>category</key>
+ <string>APPLESCRIPTS</string>
+ <key>command</key>
+ <string>#Usage : Type media play/next/prev/fave
+#Work with deezer, grooveshark and shuffler.fm. Favorite feature only works for Shuffler.fm. For more supported websites or bugs contact me @Silouane20 on twitter.
+#Assigning hotkeys to this extension improves it !
+
+on alfred_script(q)
+ set unixpath to (do shell script "pwd") &amp; "/"
+ set unixpath to unixpath &amp; q &amp; ".js"
+ set foo to (open for access (POSIX file unixpath))
+ set txt to (read foo for (get eof foo))
+ close access foo
+
+ tell application "System Events"
+ if exists (application process "Safari") then
+ tell application "Safari"
+ set W to every window
+ repeat with Wi in W
+ set T to every tab of Wi
+ repeat with Ti in T
+ tell Ti
+ do JavaScript txt
+ end tell
+ end repeat
+ end repeat
+ end tell
+ end if
+ if exists (application process "Google Chrome") then
+ tell application "Google Chrome"
+ set W to every window
+ repeat with Wi in W
+ set T to every tab of Wi
+ repeat with Ti in T
+ tell Ti
+ execute javascript txt
+ end tell
+ end repeat
+ end repeat
+ end tell
+ end if
+ end tell
+end alfred_script</string>
+ <key>disabled</key>
+ <false/>
+ <key>keyword</key>
+ <string>media</string>
+ <key>parameter</key>
+ <integer>2</integer>
+ <key>subtitle</key>
+ <string>Previous, play/pause, next track and favorite on music sites</string>
+ <key>title</key>
+ <string>Use media keys on music sites</string>
+</dict>
+</plist>
diff --git a/next.js b/next.js
index 0cd8e75..d4c71fe 100644
--- a/next.js
+++ b/next.js
@@ -9,6 +9,9 @@
else
GS.trigger("player:nextSong");
break;
+ case "shuffler.fm":
+ $('a#next')[0].click();
+ break;
}
})();
diff --git a/play.js b/play.js
index 788dc94..2f275bb 100644
--- a/play.js
+++ b/play.js
@@ -14,6 +14,10 @@
else
GS.trigger("player:togglePlay");
break;
+ case "shuffler.fm":
+ $('a#play-pause')[0].click();
+ break;
+
}
})();
diff --git a/prev.js b/prev.js
index 515bfda..ac0960b 100644
--- a/prev.js
+++ b/prev.js
@@ -9,5 +9,8 @@
else
GS.trigger("player:previousSong");
break;
+ case "shuffler.fm":
+ $('a#prev')[0].click();
+ break;
}
})();
\ No newline at end of file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment