I'm trying to make an extension that closes all tabs but the active tab for the current window in Safari. I have gotten this far as to close all tabs but index 1. But I need to insert the activetab index and exclude that from the closings. If I get the answer I'd put it in the extension and publish it.
<!DOCTYPE HTML>
<script>
safari.application.addEventListener("command", performCommand, false);
safari.application.addEventListener("validate", validateCommand, false);
function performCommand(event)
{
if (event.command !== "closer")
return;
var tabss = safari.application.activeBrowserWindow.tabs;
for (j=1; j<tabss.length; j++) {
event.target.browserWindow.activeTab.close();
}
}
</script>