2

Is it possible to use Chrome's JavaScript Console to close all tabs for a specific website or a URL/title regex - e.g. closing dozens of Stackoverflow tabs that are using up memory instead of close them one by one?

Orion
  • 1,104
  • 3
  • 16
  • 40
  • 1
    I wouldn't think this'd be possible using the JS console, since that's sandboxed to each web page and would pose a security risk if it could access top-level browser elements. You could do this using the Chrome Extensions API though (here are the docs specific to working with tabs: https://developer.chrome.com/extensions/tabs) – alexpls Jan 07 '15 at 00:57

2 Answers2

0

This is not possible to do with the JavaScript console. The JavaScript console has no way of interacting with the browser in this fashion.

Ryan Bigg
  • 106,965
  • 23
  • 235
  • 261
0

Just tried this and it seems to work in Chrome. Although it does mean that you have to programmatically open the window as well:

mywindow = window.open('', 'windowName', '', true);

then you close it with:

mywindow.close();

See this answer. Basically you need a reference to do what you're doing. You can't find by title or URL.

Community
  • 1
  • 1
Kyle Cureau
  • 19,028
  • 23
  • 75
  • 104