@@ -126,7 +126,7 @@ const renderContent = () => {
126126 if ( showTabs ) {
127127 const $tab = m ( 'a.tab' , {
128128 className : group . selected && 'selected' ,
129- onclick : ( ) => {
129+ onclick ( ) {
130130 // Remember the scroll position of the last selected group.
131131 const selectedGroup = groups . filter ( group => group . selected ) [ 0 ] ;
132132 if ( selectedGroup ) {
@@ -200,10 +200,29 @@ const renderGroupVideo = (group, video) => {
200200 openVideo ( video , inNewTab ) ;
201201 } ;
202202
203+ const link = ( selector , opts , children ) => {
204+ if ( ! opts . href ) { return m ( selector , { href : '#' , ...opts } , children ) ; }
205+ let url = opts . href . replace ( / ^ h t t p s ? : \/ \/ ( w w w \. ) ? / , '' ) ;
206+ if ( opts . target === '_blank' ) { url += ' ⇗' ; }
207+ let el ;
208+ return m ( selector , {
209+ onmouseenter ( ) {
210+ el = document . createElement ( 'div' ) ;
211+ el . className = 'mouseover-link' ;
212+ el . textContent = url ;
213+ document . body . append ( el ) ;
214+ } ,
215+ onmouseleave ( ) {
216+ if ( el ) { el . remove ( ) ; }
217+ } ,
218+ ...opts
219+ } , children ) ;
220+ } ;
221+
203222 const userView = ( user ) => {
204223 if ( ! user ) { return null ; }
205- return m ( ( user . url ? 'a' : 'span' ) + '.user' , {
206- href : user . url || '#' ,
224+ return link ( ( user . url ? 'a' : 'span' ) + '.user' , {
225+ href : user . url ,
207226 target : '_blank' ,
208227 } , [
209228 user . image ?
@@ -214,11 +233,26 @@ const renderGroupVideo = (group, video) => {
214233 ] ) ;
215234 } ;
216235
236+ const gameView = ( game ) => {
237+ // Fallback to Twitch gaming if there is a `game.name`,
238+ // but no `game.url` or `game.thumbnail`.
239+ const url = game . url || 'https://www.twitch.tv/directory/game/' +
240+ encodeURIComponent ( game . name ) + '/videos/week' ;
241+ const image = game . image ||
242+ 'http://static-cdn.jtvnw.net/ttv-boxart/' +
243+ encodeURIComponent ( game . name ) + '-138x190.jpg' ;
244+ return link ( 'a.game' , {
245+ href : url ,
246+ target : '_blank' ,
247+ 'data-title' : game . name ,
248+ } , m ( 'img.lazy' , { 'data-src' : image } ) ) ;
249+ } ;
250+
217251 const sourceView = ( source ) => {
218252 return m ( 'span.source' , [
219- m ( ( source . url ? 'a' : 'span' ) + '.favicon' , {
253+ link ( ( source . url ? 'a' : 'span' ) + '.favicon' , {
220254 className : 'source-' + source . source ,
221- href : source . url || '#' ,
255+ href : source . url ,
222256 target : '_blank' ,
223257 } )
224258 ] . concat ( source . users ?
@@ -232,26 +266,16 @@ const renderGroupVideo = (group, video) => {
232266 if ( video . silentQueued ) { vidClass += '.silent-queued' ; }
233267 if ( video . playing ) { vidClass += '.playing' ; }
234268 const $video = m ( 'li.video' + vidClass , [
235- m ( 'a.left-side' , { href : video . url , disabled : true } , [
269+ link ( 'a.left-side' , { href : video . url , disabled : true } , [
236270 m ( 'img.lazy' , {
237271 'data-src' : video . thumbnail || '' ,
238272 onclick : open . bind ( null , false ) ,
239273 } ) ,
240- video . game ?
241- m ( 'a.game' , {
242- href : video . game . url || 'https://www.twitch.tv/directory/game/' +
243- encodeURIComponent ( video . game . name ) + '/videos/week' ,
244- 'data-title' : video . game . name ,
245- target : '_blank' ,
246- } , m ( 'img.lazy' , {
247- 'data-src' : video . game . image ||
248- 'http://static-cdn.jtvnw.net/ttv-boxart/' +
249- encodeURIComponent ( video . game . name ) + '-138x190.jpg' ,
250- } ) ) : null ,
274+ video . game ? gameView ( video . game ) : null ,
251275 video . length && m ( 'span.length' , formatVideoLength ( video . length ) ) ,
252276 openedVideo && openedVideo . playing && m ( 'span.queue' , {
253277 'data-title' : 'Add to Queue' ,
254- onclick : ( ) => {
278+ onclick ( ) {
255279 const message = {
256280 tabID : tabID ,
257281 video : video ,
@@ -309,7 +333,7 @@ const renderGroupVideo = (group, video) => {
309333 group . removable && ! video . watched && m ( 'a.close' , {
310334 href : '#' ,
311335 'data-title' : 'Mark as Watched' ,
312- onclick : ( e ) => {
336+ onclick ( e ) {
313337 chrome . runtime . sendMessage ( {
314338 watched : true ,
315339 url : video . url ,
@@ -348,7 +372,7 @@ const renderGroupVideo = (group, video) => {
348372 e . preventDefault ( ) ;
349373 } ,
350374 } , m . trust ( '×' ) ) ,
351- m ( 'a.title' , {
375+ link ( 'a.title' , {
352376 href : video . url ,
353377 onclick : open . bind ( null , false )
354378 } , video . title ) ,
@@ -391,7 +415,7 @@ const renderVideos = (group) => {
391415
392416 group . $queueAll = m ( 'div.queue-all' , {
393417 className : openedVideo && openedVideo . playing && 'video-is-playing' ,
394- onclick : ( ) => {
418+ onclick ( ) {
395419 if ( openedVideo && openedVideo . playing ) {
396420 chrome . runtime . sendMessage ( {
397421 queueAll : true ,
0 commit comments