1 回答

TA貢獻(xiàn)1821條經(jīng)驗(yàn) 獲得超5個(gè)贊
好吧,如果不重定向到 chrome 網(wǎng)上商店,你就無(wú)法做到這一點(diǎn)。當(dāng)然,你也可以直接把CRX文件交給用戶(hù),讓他們親手安裝擴(kuò)展,但這顯然不是用戶(hù)體驗(yàn)的最佳選擇
解決了下一個(gè)解決方案:
安裝擴(kuò)展后立即 - 我創(chuàng)建了一個(gè)帶有我需要的頁(yè)面的選項(xiàng)卡
chrome.runtime.onInstalled.addListener(function() {
chrome.tabs.create({
url: 'https://mail.google.com',
active: true
});
return false;
});
還可以查看當(dāng)前打開(kāi)的選項(xiàng)卡并將焦點(diǎn)放在我們需要的選項(xiàng)卡上:
chrome.runtime.onInstalled.addListener(function(details) {
if ((details.reason === 'install') || (details.reason === 'update'))
{
refreshBrowser('gmail-inbox', true);
}
});
function refreshBrowser(target, bringToForeground) {
if (target !== 'gmail-inbox') return;
chrome.windows.getAll({ populate: true }, function(windows)
{
var foundExisting = false;
windows.forEach(function(win)
{
win.tabs.forEach(function(tab)
{
// Ignore tabs not matching the target.
if (target === 'gmail-inbox') {
if (!/https:\/\/(mail|inbox)\.google\.com/.test(tab.url)) return;
}
else
{
return; // Unknown target.
}
// Reload the matching tab.
chrome.tabs.reload(tab.id); // If this is the first one found, activate it.
if (bringToForeground && !foundExisting)
{
chrome.tabs.update(tab.id, { active: true }); }
foundExisting = true;
});
});
// If no gmail tab found, just open a new one.
if (bringToForeground && !foundExisting)
{
chrome.tabs.create({ url: (target === 'gmail-inbox') ? 'https://mail.google.com' : 'https://www.mixmax.com', active: true
});
}
});
}
添加回答
舉報(bào)