Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable global (Chrome-wide) shortcuts via the chrome.commands API #24

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions background.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<head>
<script src='scripts/jquery-1.6.1.min.js'></script>
<script src="scripts/init.js"></script>
<script src="scripts/player_action.js"></script>
</head>
<body>

Expand Down
26 changes: 24 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"scripts/track.js",
"scripts/lyrics.js",
"scripts/myscript.js",
"scripts/shortcuts.js",
"scripts/scrobble.js"
]
}
Expand All @@ -39,5 +38,28 @@
"default_title": "Google Play Music",
"default_popup": "popup.html"
},
"options_page": "options.html"
"options_page": "options.html",
"commands": {
"toggle-play": {
"suggested_key": {
"default": "Ctrl+Shift+P",
"windows": "MediaPlayPause"
},
"description": "Play/Pause"
},
"next-song": {
"suggested_key": {
"default": "Ctrl+Shift+Right",
"windows": "MediaNextTrack"
},
"description": "Play next song"
},
"prev-song": {
"suggested_key": {
"default": "Ctrl+Shift+Left",
"windows": "MediaPrevTrack"
},
"description": "Play previous song"
}
}
}
2 changes: 1 addition & 1 deletion options.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h3>Enable the features you'd like to use (or just <a href="#" class="enable_all
<input type="checkbox" name="notifications" value="notifications" id="notifications"> <label for="notifications">Show notifications when tracks change</label><br />
<blockquote><input disabled type="checkbox" name="mini_player" value="mini_player" id="mini_player"> <label for="notifications">Use notification window as mini-player</label><br /></blockquote>
</div>
<!-- <div class="item"><input type="checkbox" name="shortcuts" value="shortcuts" id="shortcuts"> <label for="shortcuts">Enable global keyboard shortcuts</label> (Ctrl+Shift+P to play/pause, Ctrl+Shift+Left/Right for next/previous track)<br /></div> -->
<div class="item"><input type="checkbox" name="shortcuts" value="shortcuts" id="shortcuts"> <label for="shortcuts">Enable global keyboard shortcuts</label> (View and edit shortcuts by clicking on Keyboard shortcuts in chrome://extensions)<br /></div>
<!--
<div class="item"><input type="checkbox" name="download" id="download" value="Download"> <label for="download">Insert a download button for currently playing track</label> by <a href="http://userscripts.org/scripts/show/105972">Chris Hendry</a><br /></div>
-->
Expand Down
17 changes: 15 additions & 2 deletions scripts/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,21 @@ function onRequest(request, sender, callback) {
}
}

// Wire up the listener.
chrome.extension.onRequest.addListener(onRequest);
// Wire up the listener.
chrome.extension.onRequest.addListener(onRequest);
chrome.commands.onCommand.addListener(function(command) {
if (localStorage['shortcuts'] == 'true') {
if (command == "toggle-play") {
player_action('playPause');
}
else if (command == "next-song") {
player_action('nextSong');
}
else if (command == "prev-song") {
player_action('prevSong');
}
}
});

$('body').ready(function() {
history_listener();
Expand Down
38 changes: 0 additions & 38 deletions scripts/shortcuts.js

This file was deleted.