我正在开发一个chrome扩展,我想在代码更改后自动刷新活动标签
我让gulp-open正常工作了,所以我不再需要导航到chrome://扩展并手动点击“重新加载”。
现在仅保留活动选项卡刷新
我尝试过gulp-livereload,但在开发chrome扩展时无法使用它
你有什么办法吗?
发布于 2015-12-26 01:14:21
你能把你的chrome扩展的代码贴出来吗?在没有太多信息的情况下,我希望这对你有帮助。您可以在重新加载chrome扩展后注入以下代码以刷新页面:
chrome.tabs.query({
active: true, // Select active tabs
lastFocusedWindow: true // In the current window
}, function(tabs) {
// Since there can only be one active tab in one active window,
// the array has only one element
var tab = tabs[0];
// Javascript to reload the page
var code = 'window.location.reload();';
// Execute the code for the current tab
chrome.tabs.executeScript(tab.id, {code: code});
});https://stackoverflow.com/questions/34325055
复制相似问题