mirror of
https://github.com/XFox111/TabsAsideExtension.git
synced 2026-04-22 07:58:01 +03:00
Minor 1.6 (#24)
- Added localization system (#23) - Added Russian locale (#23) - Feedback button link is now based on the extension download source (#20) - Added badge counter to the extension icon - Added keyboard shortcuts (#22) - Added action items to the extension icon context menu (#22) - Added ability to change primary extension icon action to save tabs instead of opening the pane (#22)
This commit is contained in:
+57
-2
@@ -1,4 +1,4 @@
|
||||
chrome.browserAction.onClicked.addListener((tab) =>
|
||||
function TogglePane(tab)
|
||||
{
|
||||
if (tab.url.startsWith("http")
|
||||
&& !tab.url.includes("chrome.google.com")
|
||||
@@ -38,10 +38,59 @@ chrome.browserAction.onClicked.addListener((tab) =>
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
function ProcessCommand(command)
|
||||
{
|
||||
switch(command)
|
||||
{
|
||||
case "set-aside":
|
||||
SaveCollection();
|
||||
break;
|
||||
case "toggle-pane":
|
||||
chrome.tabs.query(
|
||||
{
|
||||
active: true,
|
||||
currentWindow: true
|
||||
},
|
||||
(tabs) => TogglePane(tabs[0])
|
||||
)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
chrome.browserAction.onClicked.addListener((tab) =>
|
||||
{
|
||||
chrome.storage.sync.get({ "setAsideOnClick": false }, values =>
|
||||
{
|
||||
if (values.setAsideOnClick)
|
||||
SaveCollection();
|
||||
else
|
||||
TogglePane(tab);
|
||||
});
|
||||
});
|
||||
|
||||
// Adding context menu options
|
||||
chrome.contextMenus.create(
|
||||
{
|
||||
id: "toggle-pane",
|
||||
contexts: ['all'],
|
||||
title: chrome.i18n.getMessage("togglePaneContext")
|
||||
}
|
||||
);
|
||||
chrome.contextMenus.create(
|
||||
{
|
||||
id: "set-aside",
|
||||
contexts: ['all'],
|
||||
title: chrome.i18n.getMessage("setAside")
|
||||
}
|
||||
);
|
||||
|
||||
var collections = JSON.parse(localStorage.getItem("sets")) || [];
|
||||
|
||||
chrome.commands.onCommand.addListener(ProcessCommand);
|
||||
chrome.contextMenus.onClicked.addListener((info) => ProcessCommand(info.menuItemId));
|
||||
|
||||
chrome.runtime.onMessage.addListener((message, sender, sendResponse) =>
|
||||
{
|
||||
switch (message.command)
|
||||
@@ -88,6 +137,12 @@ function UpdateTheme()
|
||||
"16": basePath + "16.png"
|
||||
}
|
||||
});
|
||||
|
||||
// Updating badge counter
|
||||
if (collections.length < 1)
|
||||
chrome.browserAction.setBadgeText({ });
|
||||
else
|
||||
chrome.browserAction.setBadgeText({ text: collections.length.toString() });
|
||||
}
|
||||
|
||||
UpdateTheme();
|
||||
@@ -104,7 +159,7 @@ function SaveCollection()
|
||||
|
||||
if (tabs.length < 1)
|
||||
{
|
||||
alert("No tabs available to save");
|
||||
alert(chrome.i18n.getMessage("noTabsToSave"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user