Skip to content

Commit 2b1df04

Browse files
committed
Fix regex and remove commands
1 parent f280d90 commit 2b1df04

File tree

2 files changed

+5
-50
lines changed

2 files changed

+5
-50
lines changed

background.js

Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,11 @@
1111
*/
1212

1313
const forcePopup = ({ id, url }) => {
14-
if (/https?:\/\/(github|gitlab).com\/*\/*/.test(url)) {
14+
if (/https?:\/\/(github|gitlab).com\/.*\/.*/.test(url)) {
1515
chrome.pageAction.show(id);
1616
}
1717
};
1818

19-
chrome.tabs.query({active: true, currentWindow: true}, (tabs) => {
20-
forcePopup(tabs[0]);
21-
});
22-
2319
chrome.tabs.onUpdated.addListener((tabId, activeInfo, tab) => {
2420
forcePopup(tab);
2521
});
@@ -28,49 +24,9 @@ chrome.tabs.onActivated.addListener(({ tabId }) => {
2824
chrome.tabs.get(tabId, forcePopup);
2925
});
3026

31-
chrome.pageAction.onClicked.addListener((tab) => {
32-
chrome.tabs.query({active: true, lastFocusedWindow: true}, (tabs) => {
33-
const { url } = tabs[0];
34-
chrome.windows.create({
35-
url: `https://.gitpod.io/#${url}`,
36-
type: 'popup',
37-
});
27+
chrome.pageAction.onClicked.addListener(({ url }) => {
28+
chrome.windows.create({
29+
url: `https://.gitpod.io/#${url}`,
30+
type: 'popup',
3831
});
3932
});
40-
41-
/*
42-
* Shortcut disabling
43-
*
44-
* @ref: https://developer.chrome.com/extensions/commands
45-
*/
46-
47-
const handleCommand = (command) => {
48-
/*
49-
* Do nothing.
50-
*/
51-
};
52-
53-
const toggleCommandListener = ({ id, url }) => {
54-
if (/https?:\/\/*.*.gitpod.io\/*/.test(url)) {
55-
chrome.commands.onCommand.addListener(handleCommand);
56-
return;
57-
/*
58-
* Check and remove listener when user are not in a
59-
* gitpod workspace
60-
*/
61-
} else if (chrome.commands.onCommand.hasListener(handleCommand)) {
62-
chrome.commands.onCommand.removeListener(handleCommand);
63-
}
64-
};
65-
66-
chrome.tabs.onUpdated.addListener((tabId, activeInfo, tab) => {
67-
toggleCommandListener(tab);
68-
});
69-
70-
chrome.tabs.onActivated.addListener(({ tabId }) => {
71-
chrome.tabs.get(tabId, toggleCommandListener);
72-
});
73-
74-
chrome.tabs.query({active: true, currentWindow: true}, (tabs) => {
75-
toggleCommandListener(tabs[0]);
76-
});

manifest.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,5 @@
1313
"scripts": ["background.js"],
1414
"persistent": false
1515
},
16-
"commands": {},
1716
"page_action": {}
1817
}

0 commit comments

Comments
 (0)