How about just `var type = detectWeb(doc, url); var newItem = new Zotero.Item(type)`?