mirror of
https://github.com/fregante/GhostText.git
synced 2024-09-11 19:47:22 +03:00
Add shortcut to disconnect fields (#269)
This commit is contained in:
parent
034bc379f0
commit
a44a1c8edc
@ -2,13 +2,6 @@ import browser from 'webextension-polyfill';
|
||||
import oneEvent from 'one-event';
|
||||
import optionsStorage from './options-storage.js';
|
||||
|
||||
function inCurrentTab(callback) {
|
||||
chrome.tabs.query({
|
||||
active: true,
|
||||
currentWindow: true,
|
||||
}, tabs => callback(tabs[0]));
|
||||
}
|
||||
|
||||
function handleClose(info, tab) {
|
||||
chrome.tabs.executeScript(tab.id, {
|
||||
code: 'stopGT()',
|
||||
@ -140,9 +133,16 @@ function init() {
|
||||
contexts: ['browser_action'],
|
||||
onclick: handleClose,
|
||||
});
|
||||
chrome.commands.onCommand.addListener(command => {
|
||||
chrome.commands.onCommand.addListener((command, tab) => {
|
||||
if (!tab?.id) {
|
||||
console.warn('No tab information was received for command', {command, tab});
|
||||
return;
|
||||
}
|
||||
|
||||
if (command === 'open') {
|
||||
inCurrentTab(handleAction);
|
||||
handleAction(tab);
|
||||
} else if (command === 'close') {
|
||||
handleClose({}, tab);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -47,6 +47,9 @@
|
||||
"default": "Ctrl+Shift+K",
|
||||
"linux": "Ctrl+Shift+H"
|
||||
}
|
||||
},
|
||||
"close": {
|
||||
"description": "Disconnect from GhostText"
|
||||
}
|
||||
},
|
||||
"content_scripts": [
|
||||
|
Loading…
Reference in New Issue
Block a user