Skip to content

Commit 0f102ed

Browse files
committed
Make context menu always available
1 parent 12d554e commit 0f102ed

File tree

3 files changed

+3
-16
lines changed

3 files changed

+3
-16
lines changed

src/browser/extension/background/contextMenus.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ const menus = [
77
{ id: 'devtools-panel', title: 'Open in a chrome panel (enable in Chrome settings)' },
88
{ id: 'devtools-remote', title: 'Open Remote DevTools' }
99
];
10-
let pageUrl;
11-
let pageTab;
1210

1311
let shortcuts = {};
1412
chrome.commands.getAll(commands => {
@@ -17,24 +15,12 @@ chrome.commands.getAll(commands => {
1715
});
1816
});
1917

20-
export default function createMenu(forUrl, tabId) {
21-
if (typeof tabId !== 'number') return; // It is an extension's background page
22-
chrome.pageAction.show(tabId);
23-
if (tabId === pageTab) return;
24-
25-
let url = forUrl;
26-
let hash = forUrl.indexOf('#');
27-
if (hash !== -1) url = forUrl.substr(0, hash);
28-
if (pageUrl === url) return;
29-
pageUrl = url; pageTab = tabId;
30-
chrome.contextMenus.removeAll();
31-
18+
export default function createMenu() {
3219
menus.forEach(({ id, title }) => {
3320
chrome.contextMenus.create({
3421
id: id,
3522
title: title + (shortcuts[id] ? ' (' + shortcuts[id] + ')' : ''),
3623
contexts: ['all'],
37-
documentUrlPatterns: [url],
3824
onclick: () => { openDevToolsWindow(id); }
3925
});
4026
});

src/browser/extension/background/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import createDevStore from 'remotedev-app/lib/store/createDevStore';
22
import openDevToolsWindow from './openWindow';
33
import { toContentScript } from './messaging';
4+
import createMenu from './contextMenus';
45

56
const store = createDevStore((action) => {
67
toContentScript(action);
@@ -12,3 +13,4 @@ window.store.liftedStore.instances = {};
1213
chrome.commands.onCommand.addListener(shortcut => {
1314
openDevToolsWindow(shortcut);
1415
});
16+
setTimeout(createMenu, 0);

src/browser/extension/background/messaging.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { onConnect, onMessage, sendToTab } from 'crossmessaging';
22
import updateState from 'remotedev-app/lib/store/updateState';
33
import syncOptions from '../options/syncOptions';
4-
import createMenu from './contextMenus';
54
import openDevToolsWindow from './openWindow';
65
let panelConnections = {};
76
let tabConnections = {};

0 commit comments

Comments
 (0)