Skip to content

Commit

Permalink
Ignore tabs with invalid url
Browse files Browse the repository at this point in the history
  • Loading branch information
fthdgn committed Sep 12, 2020
1 parent 91bd08c commit 7bf7f85
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,13 @@ async function closeTabsFromCurrentDomainAction() {
let selectedTab = await getSelectedTab()
let domain = new URL(selectedTab.url).host
let tabs = await getAllTabs()
tabs = tabs.filter(tab => { return new URL(tab.url).host == domain })
tabs = tabs.filter(tab => {
try {
return new URL(tab.url).host == domain
} catch (error) {
return false
}
})
tabs.forEach(tab => {
chrome.tabs.remove(tab.id)
})
Expand All @@ -132,7 +138,13 @@ async function moveTabsFromCurrentDomainAction() {
let selectedTab = await getSelectedTab()
let domain = new URL(selectedTab.url).host
let tabs = await getAllTabs()
tabs = tabs.filter(tab => { return new URL(tab.url).host == domain })
tabs = tabs.filter(tab => {
try {
return new URL(tab.url).host == domain
} catch (error) {
return false
}
})
tabs.forEach(tab => {
chrome.tabs.move(tab.id, { "windowId": currentWindow.id, "index": currentWindow.tabs.length + tabs.length })
if (tab.pinned == true) {
Expand Down

0 comments on commit 7bf7f85

Please sign in to comment.