...
Code Block |
---|
function close_tabs(domain_name) { // Getget all the open windows in the browser constvar windows = window.topopen('', '_blank'); // Looploop through all eachthe open windowwindows for (letvar i = 0; i < windows.length; i++) { // Get all the tabs in the current window const tabs = windows[i].document.getElementsByTagName('a'); // Loop through each tab for (let j = 0; j < tabs.length; j++) { // Checkcheck if the tabwindow's URL containsincludes domain_name if (tabswindows[ji].location.href.includesindexOf(domain_name)) > -1) { // Closeclose the tabwindow windows[i].close(); } } } } close_tabs( "foo.com"); |