- <xsl:template match="//div[@class='permalink-inner permalink-tweet-container'] | //li[@data-item-id and @data-item-type='tweet']">
- <xsl:variable name="user-name" select=".//div[@data-tweet-id]/@data-screen-name"/>
- <xsl:variable name="item-content" select=".//p[contains(@class, 'js-tweet-text')]"/>
- <xsl:variable name="item-media" select=".//div[contains(@class, 'AdaptiveMedia-container')]"/>
- <xsl:variable name="item-permalink" select="concat($BaseURL, .//div[@data-permalink-path]/@data-permalink-path)"/>
+ <xsl:template match="//div[contains(@class, 'timeline')]/table[@class='tweet ']|//div[@class='main-tweet-container']/table[@class='main-tweet']">
+ <xsl:variable name="user-name" select="normalize-space(.//*[@class='username']/text()[2])"/>
+ <xsl:variable name="item-content" select=".//div[@class='tweet-text']/div"/>
+ <xsl:variable name="item-media" select=".//a[@data-pre-embedded='true']"/>
+ <xsl:variable name="item-permalink">
+ <xsl:choose>
+ <xsl:when test="@href">
+ <xsl:value-of select="concat($BaseURL, substring-before(@href, '?'))"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <!--
+ The main tweet in permalink pages do not have a timestamp tag,
+ just use the canonical URL as permalink.
+ -->
+ <xsl:value-of select="//link[@rel='canonical']/@href"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- TODO twitter mobile UI does not have a way to detect this
+ <xsl:variable name="item-has-video" select="$item-media//*[contains(@class, 'PlayableMedia- -video')]"/>
+ <xsl:variable name="item-has-gif" select="$item-media//*[contains(@class, 'PlayableMedia- -gif')]"/>
+ -->