Join the AMA (Ask Me Anything) with the Firefox leadership team to celebrate Firefox 20th anniversary and discuss Firefox’s future on Mozilla Connect. Mark your calendar on Thursday, November 14, 18:00 - 20:00 UTC!

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.

Buscar en Ayuda

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

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

  • 1 respuesta
  • 1 tiene este problema
  • 2 visitas
  • Última respuesta de 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.

Todas las respuestas (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));