mirror of
https://github.com/alyssaxuu/omni.git
synced 2026-03-11 08:54:35 +00:00
perf: use "tabs.create" instead of "window.open"
This commit is contained in:
parent
8d78b8fe1a
commit
af289515ed
5 changed files with 25 additions and 12 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1 +1,2 @@
|
|||
.history
|
||||
.history
|
||||
.idea
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ browser.commands.onCommand.addListener((command) => {
|
|||
browser.tabs.sendMessage(response.id, {request: "open-omni"});
|
||||
} else {
|
||||
browser.tabs.create({
|
||||
url: "./newtab.html"
|
||||
url: "./newtab.html"
|
||||
}).then(() => {
|
||||
newtaburl = response.url;
|
||||
browser.tabs.remove(response.id);
|
||||
|
|
@ -241,7 +241,7 @@ const getTabs = () => {
|
|||
// Get bookmarks to populate in the actions
|
||||
const getBookmarks = () => {
|
||||
const process_bookmark = (bookmarks) => {
|
||||
for (const bookmark of bookmarks) {
|
||||
for (const bookmark of bookmarks) {
|
||||
if (bookmark.url) {
|
||||
actions.push({title:bookmark.title, desc:"Bookmark", id:bookmark.id, url:bookmark.url, type:"bookmark", action:"bookmark", emoji:true, emojiChar:"⭐️", keycheck:false})
|
||||
}
|
||||
|
|
@ -280,6 +280,9 @@ const duplicateTab = (tab) => {
|
|||
browser.tabs.duplicate(response.id);
|
||||
})
|
||||
}
|
||||
const createTab = (tab = {}) => {
|
||||
browser.tabs.create(tab)
|
||||
}
|
||||
const createBookmark = (tab) => {
|
||||
getCurrentTab().then((response) => {
|
||||
browser.bookmarks.create({
|
||||
|
|
@ -373,6 +376,9 @@ browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
|||
case "duplicate-tab":
|
||||
duplicateTab(message.tab);
|
||||
break;
|
||||
case "new-tab":
|
||||
createTab(message.tab);
|
||||
break;
|
||||
case "create-bookmark":
|
||||
createBookmark(message.tab);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ $(document).ready(() => {
|
|||
});
|
||||
keys += "</div>";
|
||||
}
|
||||
|
||||
|
||||
// Check if the action has an emoji or a favicon
|
||||
if (!action.emoji) {
|
||||
var onload = 'if ("naturalHeight" in this) {if (this.naturalHeight + this.naturalWidth === 0) {this.onerror();return;}} else if (this.width + this.height == 0) {this.onerror();return;}';
|
||||
|
|
@ -280,7 +280,7 @@ $(document).ready(() => {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$(".omni-extension #omni-results").html($("#omni-extension #omni-list .omni-item:visible").length+" results");
|
||||
$(".omni-item-active").removeClass("omni-item-active");
|
||||
$(".omni-extension #omni-list .omni-item:visible").first().addClass("omni-item-active");
|
||||
|
|
@ -333,8 +333,8 @@ $(document).ready(() => {
|
|||
elem.requestFullscreen();
|
||||
break;
|
||||
case "new-tab":
|
||||
window.open("");
|
||||
break;
|
||||
browser.runtime.sendMessage({request:"new-tab"})
|
||||
break;
|
||||
case "email":
|
||||
window.open("mailto:");
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ chrome.commands.onCommand.addListener((command) => {
|
|||
chrome.tabs.sendMessage(response.id, {request: "open-omni"});
|
||||
} else {
|
||||
chrome.tabs.create({
|
||||
url: "./newtab.html"
|
||||
url: "./newtab.html"
|
||||
}).then(() => {
|
||||
newtaburl = response.url;
|
||||
chrome.tabs.remove(response.id);
|
||||
|
|
@ -243,7 +243,7 @@ const getTabs = () => {
|
|||
// Get bookmarks to populate in the actions
|
||||
const getBookmarks = () => {
|
||||
const process_bookmark = (bookmarks) => {
|
||||
for (const bookmark of bookmarks) {
|
||||
for (const bookmark of bookmarks) {
|
||||
if (bookmark.url) {
|
||||
actions.push({title:bookmark.title, desc:"Bookmark", id:bookmark.id, url:bookmark.url, type:"bookmark", action:"bookmark", emoji:true, emojiChar:"⭐️", keycheck:false})
|
||||
}
|
||||
|
|
@ -282,6 +282,9 @@ const duplicateTab = (tab) => {
|
|||
chrome.tabs.duplicate(response.id);
|
||||
})
|
||||
}
|
||||
const createTab = (tab = {}) => {
|
||||
chrome.tabs.create(tab)
|
||||
}
|
||||
const createBookmark = (tab) => {
|
||||
getCurrentTab().then((response) => {
|
||||
chrome.bookmarks.create({
|
||||
|
|
@ -375,6 +378,9 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
|||
case "duplicate-tab":
|
||||
duplicateTab(message.tab);
|
||||
break;
|
||||
case "new-tab":
|
||||
createTab(message.tab);
|
||||
break;
|
||||
case "create-bookmark":
|
||||
createBookmark(message.tab);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ $(document).ready(() => {
|
|||
});
|
||||
keys += "</div>";
|
||||
}
|
||||
|
||||
|
||||
// Check if the action has an emoji or a favicon
|
||||
if (!action.emoji) {
|
||||
var onload = 'if ("naturalHeight" in this) {if (this.naturalHeight + this.naturalWidth === 0) {this.onerror();return;}} else if (this.width + this.height == 0) {this.onerror();return;}';
|
||||
|
|
@ -279,7 +279,7 @@ $(document).ready(() => {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$(".omni-extension #omni-results").html($("#omni-extension #omni-list .omni-item:visible").length+" results");
|
||||
$(".omni-item-active").removeClass("omni-item-active");
|
||||
$(".omni-extension #omni-list .omni-item:visible").first().addClass("omni-item-active");
|
||||
|
|
@ -332,7 +332,7 @@ $(document).ready(() => {
|
|||
elem.requestFullscreen();
|
||||
break;
|
||||
case "new-tab":
|
||||
window.open("");
|
||||
chrome.runtime.sendMessage({request:"new-tab"})
|
||||
break;
|
||||
case "email":
|
||||
window.open("mailto:");
|
||||
|
|
|
|||
Loading…
Reference in a new issue