-
Notifications
You must be signed in to change notification settings - Fork 2k
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
希望能支持全局快捷键 #145
Labels
Comments
"commands": {
"play_next": {
"suggested_key": {
"default": "Ctrl+Shift+Right",
"mac": "Command+Shift+Right"
},
"description": "Play next song.",
"global": true
},
"play_prev": {
"suggested_key": {
"default": "Ctrl+Shift+Left",
"mac": "Command+Shift+Left"
},
"description": "Play previous song.",
"global": true
},
"play_pause": {
"suggested_key": {
"default": "Ctrl+Shift+O",
"mac": "Command+Shift+O"
},
"description": "Toggle play pause state.",
"global": true
},
// .... ...
// chrome 最多支持自动设置4个快捷键,更多快捷键可以声明,但是需要用户手动去扩展页面设置启用
} 在 let listen1Tab = undefined // listen1Tab的赋值在创建listen1.html的回调中 listen1Tab = tab
// some code
// at end of background.js
chrome.commands.onCommand.addListener(function (command) {
const [viewWindow] = chrome.extension.getViews({
type: 'tab',
tabId: listen1Tab.id
});
switch (command) {
case 'play_next':
// 此处也可以通过contentScript来做吧,对ng不熟,直接dom操作了…
viewWindow.document.querySelector('.next').click();
break;
case 'play_prev':
viewWindow.document.querySelector('.previous').click();
break;
case 'play_pause':
viewWindow.document.querySelector('.play').click();
break;
default:
console.log('不支持的快捷键')
}
}); 对ng不熟,在此抛砖引玉,希望repo主能支持全局快捷键的功能,这样切歌就不用切换到listen1的页面去了,岂不美哉… |
发了个pr,repo主考虑下… |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
貌似可以实现全局快捷键,参考:
https://developer.chrome.com/apps/commands
不然每次切歌都要切换到listen1页面去还是很麻烦…
The text was updated successfully, but these errors were encountered: