That seems to work.

Would it be possible, I wonder, to make window.external.editdisc accept the name (e.g. "Misc") of a tab? That way if new tabs got added, it wouldn't break code written with indexes.