-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 743be01
Showing
7 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Fatih Doğan | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
### Organize Windows and Tabs Extension for Google Chrome | ||
|
||
This extension adds these functions: | ||
* Extension icon primary function: | ||
Merge all windows on target window, and sorts all tabs according to tab url alphabetically. | ||
* Extension icon right click function: Close tabs from this domain: | ||
Closes all tabs with same domain. | ||
|
||
This extension ignores pinned tabs and popup windows such as web apps. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
function sortAndMergeTabs() { | ||
chrome.windows.getCurrent(function (currentWindow) { | ||
chrome.windows.getAll({ "populate": true }, function (windows) { | ||
tabs = [] | ||
windows.forEach(window => { | ||
if (window.type != "popup") { | ||
window.tabs.forEach(tab => { | ||
if (tab.pinned != true) { | ||
tabs.push(tab) | ||
} | ||
}) | ||
} | ||
}) | ||
tabs.sort(function (a, b) { | ||
if (a.url < b.url) { | ||
return -1 | ||
} else if (a.url > b.url) { | ||
return 1 | ||
} else { | ||
return 0 | ||
} | ||
}) | ||
tabs.forEach(tab => { | ||
chrome.tabs.move(tab.id, | ||
{ "windowId": currentWindow.id, "index": tabs.length * 2 }); | ||
}) | ||
}); | ||
}) | ||
} | ||
|
||
function closeTabsFromCurrentDomain() { | ||
chrome.tabs.getSelected(tab => { | ||
var url = new URL(tab.url) | ||
closeTabsFromDomain(url.host) | ||
}) | ||
} | ||
|
||
function closeTabsFromDomain(domain) { | ||
|
||
chrome.windows.getAll({ "populate": true }, function (windows) { | ||
tabs = [] | ||
windows.forEach(window => { | ||
if (window.type != "popup") { | ||
window.tabs.forEach(tab => { | ||
if (tab.pinned != true) { | ||
var url = new URL(tab.url) | ||
if (url.host == domain) { | ||
chrome.tabs.remove(tab.id) | ||
} | ||
} | ||
}) | ||
} | ||
}) | ||
}); | ||
} | ||
|
||
chrome.browserAction.onClicked.addListener(sortAndMergeTabs); | ||
|
||
chrome.contextMenus.onClicked.addListener(event => { | ||
if (event.menuItemId == "close_tabs_from_this_domain") { | ||
closeTabsFromCurrentDomain() | ||
} | ||
}) | ||
|
||
chrome.contextMenus.create({ | ||
"title": "Close tabs from this domain", | ||
"id": "close_tabs_from_this_domain", | ||
contexts: ["browser_action"], | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"background": { | ||
"persistent": false, | ||
"scripts": [ | ||
"background.js" | ||
] | ||
}, | ||
"browser_action": { | ||
"default_icon": "icons/48.png", | ||
"default_title": "Organize Windows and Tabs" | ||
}, | ||
"homepage_url": "https://github.com/fthdgn/chrome_organize_windows_tabs/", | ||
"description": "Organize Windows and Tabs", | ||
"icons": { | ||
"128": "icons/128.png", | ||
"48": "icons/48.png", | ||
"16": "icons/16.png" | ||
}, | ||
"manifest_version": 2, | ||
"name": "Organize Windows and Tabs", | ||
"offline_enabled": true, | ||
"permissions": [ | ||
"tabs", | ||
"contextMenus" | ||
], | ||
"version": "1.0.0" | ||
} |