We present an extension of the Johansen-Ledoit-Sornette (JLS) model that includes an additional pricing factor called the "Zipf factor", which describes the diversification risk of the stock market portfolio. Keeping all the dynamical characteristics of a bubble given in the JLS model, the new model provides additional information about the concentration of stock gains over time. This allows us to understand risk diversification better and to explain investors' behavior during the lifetime of the bubble. We apply this new model to three famous recent stock bubbles: the Shanghai stock exchange bubble from August 2006 to October 2007 (bubble 1), the Shanghai stock exchange bubble from October 2008 to August 2009 (bubble 2), and the S&P 500 bubble from March 2004 to July 2007 (bubble 3). The Zipf factor is found to be highly significant for bubble 1, which corresponds to the fact that valuation gains were more concentrated on the large firms of the Shanghai index. It is likely that the widespread acknowledgement of the 80-20 rule in the Chinese media and discussion forums led many investors to discount the risk of a lack of diversification, thereby enhancing the role of the Zipf factor. For bubble 2, the Zipf factor is found to be negative, suggesting a larger weight of market gains on small firms. We interpret this result as a consequence of the Chinese economy's response to the very large stimulus provided by the Chinese government in the aftermath of the 2008 financial crisis. For bubble 3, the Zipf factor is marginally relevant, suggesting that market gains are approximately equally distributed between large and small firms. A trading strategy based on the combination of the Zipf factor and the JLS analysis is then developed and tested. An analysis of its performance characteristics shows that the introduction of the Zipf factor increases returns significantly.