This site will have limited functionality while we undergo maintenance to improve your experience. If an article doesn't solve your issue and you want to ask a question, we have our support community waiting to help you at @FirefoxSupport on Twitter and/r/firefox on Reddit.

Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Èròjà atẹ̀lélànà yii ni a ti fi pamọ́ fọ́jọ́ pípẹ́. Jọ̀wọ́ béèrè ìbéèrè titun bí o bá nílò ìrànwọ́.

Is there an extension that will allow one to close tabs that contain in their titles a given string of characters?

  • 1 èsì
  • 1 ní ìṣòro yìí
  • 2 views
  • Èsì tí ó kẹ́hìn lọ́wọ́ cor-el

more options

I have searched, but I cannot find an extension that will enable the closing of tabs that contain a given string of characters in their titles. If such an extension also enabled other actions to such tabs, such as moving them to another window, that would be great. Thanks for your help, if you can.

I have searched, but I cannot find an extension that will enable the closing of tabs that contain a given string of characters in their titles. If such an extension also enabled other actions to such tabs, such as moving them to another window, that would be great. Thanks for your help, if you can.

All Replies (1)

more options

The only extension I know that deals with multiple tabs is the Multiple Tab Handler extension

If you know something about programming then you can use this JavaScript code as a start. R sets the regular expression to match the title and T sets the maximum number of tabs to close starting with the last tab and counting backward. With T=0 no tabs are removed, so use this to test the regular expression R. Use this at your own risk. Note that you can undo closed tabs up to the maximum as set via browser.sessionstore.max_tabs_undo and possibly set T=1 to close one tab each time you click Run.

You can use the Scratchpad and run the JavaScript code posted below.

  • open the Environment menu in the Scratchpad and select Browser to run the JavaScript code in Browser context
  • paste the JavaScript code in the editor area
  • click Run to run the JavaScript code

You can see messages in the Browser Console.


var R = RegExp("firefox","i"), T=0;
var wm = Services.wm;
var gB = wm.getMostRecentWindow("navigator:browser").gBrowser;
var tC = gB.mTabContainer;

function objURI(t,u,n){with(this){tab=t; uri=u; name=n;}}
objURI.prototype={tab:"", uri:"", name:""};

var lC = gB.mPanelContainer.childNodes.length, i, t=[], u;
for(i=lC-1; i>=0; i--){
cD=gB.getBrowserAtIndex(i).contentDocument;
if(R.test(cD.title)){
 u=new objURI(i, cD.location.href, cD.title);
 t.push(u);
 if(T){
  T--; 
  tC.selectedIndex = i;
  BrowserCloseTabOrWindow();
  console.log("closed",i, cD.title);
 }
}
}
console.log(JSON.stringify(t, null, 1));