mirror of
https://github.com/GoogleChrome/chrome-extensions-samples.git
synced 2026-03-27 13:29:34 +07:00
Convert Tab Flipper to MV3 (#679)
This commit is contained in:
16
api/default_command_override/background.js
Normal file
16
api/default_command_override/background.js
Normal file
@@ -0,0 +1,16 @@
|
||||
// Copyright 2017 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
chrome.commands.onCommand.addListener(async (command) => {
|
||||
const tabs = await chrome.tabs.query({ currentWindow: true });
|
||||
// Sort tabs according to their index in the window.
|
||||
tabs.sort((a, b) => { return a.index < b.index; });
|
||||
let activeIndex = tabs.findIndex((tab) => { return tab.active; });
|
||||
let lastTab = tabs.length - 1;
|
||||
let newIndex = -1;
|
||||
if (command === 'flip-tabs-forward')
|
||||
newIndex = activeIndex === 0 ? lastTab : activeIndex - 1;
|
||||
else // 'flip-tabs-backwards'
|
||||
newIndex = activeIndex === lastTab ? 0 : activeIndex + 1;
|
||||
chrome.tabs.update(tabs[newIndex].id, { active: true, highlighted: true });
|
||||
});
|
||||
BIN
api/default_command_override/images/tabFlipper128.png
Normal file
BIN
api/default_command_override/images/tabFlipper128.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.0 KiB |
BIN
api/default_command_override/images/tabFlipper16.png
Normal file
BIN
api/default_command_override/images/tabFlipper16.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 473 B |
BIN
api/default_command_override/images/tabFlipper32.png
Normal file
BIN
api/default_command_override/images/tabFlipper32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1007 B |
BIN
api/default_command_override/images/tabFlipper48.png
Normal file
BIN
api/default_command_override/images/tabFlipper48.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
35
api/default_command_override/manifest.json
Normal file
35
api/default_command_override/manifest.json
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "Tab Flipper",
|
||||
"description": "Press Ctrl+Shift+Right or Ctrl+Shift+Left (Command+Shift+Right or Command+Shift+Left on a Mac) to flip through window tabs",
|
||||
"version": "1.0",
|
||||
"manifest_version": 3,
|
||||
"background": {
|
||||
"service_worker": "background.js"
|
||||
},
|
||||
"action": {
|
||||
"default_icon": "images/tabFlipper16.png",
|
||||
"default_title": "Press Ctrl(Win)/Command(Mac)+Shift+ Left or Right to Flip Tabs"
|
||||
},
|
||||
"commands": {
|
||||
"flip-tabs-forward": {
|
||||
"suggested_key": {
|
||||
"default": "Ctrl+Shift+Right",
|
||||
"mac": "Command+Shift+Right"
|
||||
},
|
||||
"description": "Flip tabs forward"
|
||||
},
|
||||
"flip-tabs-backwards": {
|
||||
"suggested_key": {
|
||||
"default": "Ctrl+Shift+Left",
|
||||
"mac": "Command+Shift+Left"
|
||||
},
|
||||
"description": "Flip tabs backwards"
|
||||
}
|
||||
},
|
||||
"icons": {
|
||||
"16": "images/tabFlipper16.png",
|
||||
"32": "images/tabFlipper32.png",
|
||||
"48": "images/tabFlipper48.png",
|
||||
"128": "images/tabFlipper128.png"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user