-2
我正在研究Google Chrome扩展程序。将代码移至单独的功能
我有这样同样的问题:Right click menu disappears after restarting the browser
的解决方案是使用:
chrome.runtime.onInstalled .addListener(函数(){ chrome.runtime.onStartup。 addListener(function(){
我已经测试过它,但是现在我有重复代码:
//context menu
chrome.runtime.onInstalled.addListener(function() {
chrome.contextMenus.create({
title: '1',
id: 'a',
contexts: ['all'],
});
});
chrome.runtime.onStartup.addListener(function() {
chrome.contextMenus.create({
title: '1',
id: 'a',
contexts: ['all'],
});
});
我该如何缩短代码?我真的很陌生,非常感谢!
哇,超级快。非常感谢你,它的工作! – Aldunnord
你能标记为正确答案吗? – hackerrdave