Is there an extension that will allow one to close tabs that contain in their titles a given string of characters?
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.
Сви одговори (1)
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));