Add Omni on install without reloading

This commit is contained in:
Alyssa X 2022-01-11 16:13:08 +00:00
parent a80cb5e295
commit 6dbe57d978
2 changed files with 30 additions and 2 deletions

View file

@ -1,5 +1,33 @@
var actions = [];
// Inject Omni on install
chrome.manifest = chrome.runtime.getManifest();
var injectIntoTab = function (tab) {
var scripts = chrome.manifest.content_scripts[0].js;
var i = 0, s = scripts.length;
for( ; i < s; i++ ) {
chrome.scripting.executeScript({
target: {tabId: tab.id},
files: [scripts[i]]
});
}
}
// Get all windows
chrome.windows.getAll({
populate: true
}, function (windows) {
var i = 0, w = windows.length, currentWindow;
for( ; i < w; i++ ) {
currentWindow = windows[i];
var j = 0, t = currentWindow.tabs.length, currentTab;
for( ; j < t; j++ ) {
currentTab = currentWindow.tabs[j];
injectIntoTab(currentTab);
}
}
});
// Clear actions and append default ones
function clearActions() {
getCurrentTab().then((response) => {

View file

@ -2,7 +2,7 @@
"name": "Omni",
"description": "Supercharge Chrome with commands, shortcuts, and more",
"offline_enabled": true,
"version": "1.0.1",
"version": "1.0.2",
"manifest_version": 3,
"action": {
"icons": {
@ -45,7 +45,7 @@
}
],
"permissions": [
"tabs", "activeTab", "bookmarks", "browsingData", "history"
"tabs", "activeTab", "bookmarks", "browsingData", "history", "scripting"
],
"host_permissions": [
"https://www.googleapis.com/*", "https://gstatic.com/*", "*://*/*"