Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bugs and added a feature. #118

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const clearActions = () => {
const isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0;
let muteaction = {title:"Mute tab", desc:"Mute the current tab", type:"action", action:"mute", emoji:true, emojiChar:"🔇", keycheck:true, keys:['⌥','⇧', 'M']};
let pinaction = {title:"Pin tab", desc:"Pin the current tab", type:"action", action:"pin", emoji:true, emojiChar:"📌", keycheck:true, keys:['⌥','⇧', 'P']};
if (response.mutedInfo.muted) {
if (response?.mutedInfo?.muted) {
muteaction = {title:"Unmute tab", desc:"Unmute the current tab", type:"action", action:"unmute", emoji:true, emojiChar:"🔈", keycheck:true, keys:['⌥','⇧', 'M']};
}
if (response.pinned) {
if (response?.pinned) {
pinaction = {title:"Unpin tab", desc:"Unpin the current tab", type:"action", action:"unpin", emoji:true, emojiChar:"📌", keycheck:true, keys:['⌥','⇧', 'P']};
}
actions = [
Expand Down Expand Up @@ -475,10 +475,17 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
}
break;
case "search":
chrome.search.query(
{text:message.query}
)
break;
var query = () =>
chrome.search.query({
text: message.query,
disposition: message.disposition,
});
if (message.__inNewTab__) {
setTimeout(query, 125);
} else {
query();
}
break;
case "restore-new-tab":
restoreNewTab();
break;
Expand Down
3 changes: 3 additions & 0 deletions src/content.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.omni-extension {
text-align: left;
}
/* Scrollbar size */
.omni-extension ::-webkit-scrollbar {
width: 10px;
Expand Down
8 changes: 5 additions & 3 deletions src/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ $(document).ready(() => {
// Request actions from the background
chrome.runtime.sendMessage({request:"get-actions"}, (response) => {
actions = response.actions;
populateOmni()
});

// New tab page workaround
if (window.location.href == "chrome-extension://mpanekjjajcabgnlbabmopeenljeoggm/newtab.html") {
if (window.__inNewTab__) {
isOpen = true;
$("#omni-extension").removeClass("omni-closing");
window.setTimeout(() => {
Expand Down Expand Up @@ -131,7 +132,7 @@ $(document).ready(() => {

// Close the omni
function closeOmni() {
if (window.location.href == "chrome-extension://mpanekjjajcabgnlbabmopeenljeoggm/newtab.html") {
if (window.__inNewTab__) {
chrome.runtime.sendMessage({request:"restore-new-tab"});
} else {
isOpen = false;
Expand Down Expand Up @@ -304,7 +305,8 @@ $(document).ready(() => {
window.open($(".omni-item-active").attr("data-url"), "_self");
}
} else {
chrome.runtime.sendMessage({request:action.action, tab:action, query:$(".omni-extension input").val()});
var disposition = window.__inNewTab__ ? "CURRENT_TAB" : e.altKey || e.metaKey ? "NEW_TAB" : "CURRENT_TAB";
chrome.runtime.sendMessage({request:action.action,__inNewTab__:window.__inNewTab__, disposition:disposition, tab:action, query:$(".omni-extension input").val()});
switch (action.action) {
case "bookmark":
if (e.ctrlKey || e.metaKey) {
Expand Down
2 changes: 1 addition & 1 deletion src/newtab.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</style>
</head>
<body>

<script src="newtab.js"></script>
<script src="jquery.js"></script>
<script src="content.js"></script>
<script src="virtualized-list.min.js"></script>
Expand Down
1 change: 1 addition & 0 deletions src/newtab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
window.__inNewTab__ = true;