How to close duplicated tabs in your Chrome browser

Open a New Tab
Press F12 to open Web Developer Tool
Open Console tab
Paste these code, and press ENTER to run:

chrome.tabs.query({}, function(tabs) {
    var firstSee = [];
    for (var i = 0; i < tabs.length; i++) {
        var url = tabs[i].url;
        var id = tabs[i].id;
        if (firstSee.indexOf(url) >= 0){
            chrome.tabs.remove(id);
        } else{
            firstSee.push(url);
        }
    }
})

Bonus: you can create a Bookmarklet to do it:

javascript:chrome.tabs.query({}, function(tabs) {var firstSee = [];for (var i = 0; i < tabs.length; i++) {var url = tabs[i].url;var id = tabs[i].id;if (firstSee.indexOf(url) >= 0){chrome.tabs.remove(id);} else{firstSee.push(url);}}})

Then open a New Tab, click that Bookmarklet. Done!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s