Add reload context menu item (#848)
* Add reload context menu item * Recheck on initial install * convert createContextMenus to function * reload command
This commit is contained in:
parent
438fdebc5c
commit
02a575a9d6
|
@ -1145,6 +1145,10 @@
|
||||||
"message": "Temporarily applies the changes without saving.\nSave the style to make the changes permanent.",
|
"message": "Temporarily applies the changes without saving.\nSave the style to make the changes permanent.",
|
||||||
"description": "Tooltip for the checkbox in style editor to enable live preview while editing."
|
"description": "Tooltip for the checkbox in style editor to enable live preview while editing."
|
||||||
},
|
},
|
||||||
|
"reload": {
|
||||||
|
"message": "Reload Stylus extension",
|
||||||
|
"description": "Context menu reload"
|
||||||
|
},
|
||||||
"replace": {
|
"replace": {
|
||||||
"message": "Replace",
|
"message": "Replace",
|
||||||
"description": "Label before the replace input field in the editor shown on Ctrl-H"
|
"description": "Label before the replace input field in the editor shown on Ctrl-H"
|
||||||
|
|
|
@ -168,6 +168,9 @@ chrome.runtime.onInstalled.addListener(({reason}) => {
|
||||||
// "normal" = addon installed from webstore
|
// "normal" = addon installed from webstore
|
||||||
chrome.management.getSelf(info => {
|
chrome.management.getSelf(info => {
|
||||||
localStorage.installType = info.installType;
|
localStorage.installType = info.installType;
|
||||||
|
if (reason === 'install' && info.installType === 'development' && chrome.contextMenus) {
|
||||||
|
createContextMenus(['reload']);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (reason !== 'update') return;
|
if (reason !== 'update') return;
|
||||||
|
@ -187,6 +190,7 @@ browserCommands = {
|
||||||
styleDisableAll(info) {
|
styleDisableAll(info) {
|
||||||
prefs.set('disableAll', info ? info.checked : !prefs.get('disableAll'));
|
prefs.set('disableAll', info ? info.checked : !prefs.get('disableAll'));
|
||||||
},
|
},
|
||||||
|
reload: () => chrome.runtime.reload(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// *************************************************************************
|
// *************************************************************************
|
||||||
|
@ -208,6 +212,11 @@ contextMenus = {
|
||||||
title: 'openOptions',
|
title: 'openOptions',
|
||||||
click: browserCommands.openOptions,
|
click: browserCommands.openOptions,
|
||||||
},
|
},
|
||||||
|
'reload': {
|
||||||
|
presentIf: () => localStorage.installType === 'development',
|
||||||
|
title: 'reload',
|
||||||
|
click: browserCommands.reload,
|
||||||
|
},
|
||||||
'editor.contextDelete': {
|
'editor.contextDelete': {
|
||||||
presentIf: () => !FIREFOX && prefs.get('editor.contextDelete'),
|
presentIf: () => !FIREFOX && prefs.get('editor.contextDelete'),
|
||||||
title: 'editDeleteText',
|
title: 'editDeleteText',
|
||||||
|
@ -220,8 +229,7 @@ contextMenus = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (chrome.contextMenus) {
|
function createContextMenus(ids) {
|
||||||
const createContextMenus = ids => {
|
|
||||||
for (const id of ids) {
|
for (const id of ids) {
|
||||||
let item = contextMenus[id];
|
let item = contextMenus[id];
|
||||||
if (item.presentIf && !item.presentIf()) {
|
if (item.presentIf && !item.presentIf()) {
|
||||||
|
@ -240,8 +248,9 @@ if (chrome.contextMenus) {
|
||||||
delete item.click;
|
delete item.click;
|
||||||
chrome.contextMenus.create(item, ignoreChromeError);
|
chrome.contextMenus.create(item, ignoreChromeError);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
if (chrome.contextMenus) {
|
||||||
// circumvent the bug with disabling check marks in Chrome 62-64
|
// circumvent the bug with disabling check marks in Chrome 62-64
|
||||||
const toggleCheckmark = CHROME >= 3172 && CHROME <= 3288 ?
|
const toggleCheckmark = CHROME >= 3172 && CHROME <= 3288 ?
|
||||||
(id => chrome.contextMenus.remove(id, () => createContextMenus([id]) + ignoreChromeError())) :
|
(id => chrome.contextMenus.remove(id, () => createContextMenus([id]) + ignoreChromeError())) :
|
||||||
|
@ -299,7 +308,6 @@ function webNavUsercssInstallerFF(data) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function webNavIframeHelperFF({tabId, frameId}) {
|
function webNavIframeHelperFF({tabId, frameId}) {
|
||||||
if (!frameId) return;
|
if (!frameId) return;
|
||||||
msg.sendTab(tabId, {method: 'ping'}, {frameId})
|
msg.sendTab(tabId, {method: 'ping'}, {frameId})
|
||||||
|
|
|
@ -59,6 +59,9 @@
|
||||||
"openManage": {
|
"openManage": {
|
||||||
"description": "__MSG_openManage__"
|
"description": "__MSG_openManage__"
|
||||||
},
|
},
|
||||||
|
"reload": {
|
||||||
|
"description": "__MSG_reload__"
|
||||||
|
},
|
||||||
"styleDisableAll": {
|
"styleDisableAll": {
|
||||||
"description": "__MSG_disableAllStyles__"
|
"description": "__MSG_disableAllStyles__"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user