@@ -43,90 +43,56 @@ let handlersUtil = {
4343 return ;
4444 }
4545
46- if ( commonUtil . isForGithUbNewUi ( ) ) {
47- setTimeout ( function ( ) {
48- commonUtil . removePrevInstancesOf ( '.eg-download' ) ; // remove before adding new ones
49-
50- const containerItems = document . querySelectorAll (
51- '.js-navigation-container.js-active-navigation-container .js-navigation-item'
52- ) ;
53-
54- let actualDataIndex = 0 ;
55-
56- for ( var i = 0 ; i < containerItems . length ; i ++ ) {
57- const commitElem = containerItems [ i ] . querySelector ( '.commit-message' ) ;
58-
59- if ( commitElem ) {
60- containerItems [ i ] . querySelector ( 'div:nth-of-type(2)' ) . classList . remove ( 'col-md-2' , 'mr-3' ) ;
61- containerItems [ i ] . querySelector ( 'div:nth-of-type(2)' ) . classList . add ( 'col-md-1' , 'mr-2' ) ;
62-
63- if ( data [ actualDataIndex ] . type === 'file' ) {
64- let formattedFileSize = commonUtil . getFileSizeAndUnit ( data [ actualDataIndex ] ) ;
65-
66- let html = `
67- <div role="gridcell" class="mr-1 text-gray-light eg-download" style="width: 95px;">
68- <span class="css-truncate css-truncate-target d-block">
69- <span style="margin-right: 5px;">
70- ${ formattedFileSize }
71- </span>
72- <a style="float: right" href="${ data [ actualDataIndex ] . download_url } " title="(Alt/Option/Ctrl + Click) to download File" aria-label="(Alt/Option/Ctrl + Click) to download File" class="tooltipped tooltipped-s"
73- download="${ data [ actualDataIndex ] . name } ">
74- <svg class="octicon octicon-cloud-download" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16">
75- <path d="M9 12h2l-3 3-3-3h2V7h2v5zm3-8c0-.44-.91-3-4.5-3C5.08 1 3 2.92 3 5 1.02 5 0 6.52 0 8c0 1.53 1 3 3 3h3V9.7H3C1.38 9.7 1.3 8.28 1.3 8c0-.17.05-1.7 1.7-1.7h1.3V5c0-1.39 1.56-2.7 3.2-2.7 2.55 0 3.13 1.55 3.2 1.8v1.2H12c.81 0 2.7.22 2.7 2.2 0 2.09-2.25 2.2-2.7 2.2h-2V11h2c2.08 0 4-1.16 4-3.5C16 5.06 14.08 4 12 4z"></path>
76- </svg>
77- </a>
78- </span>
79- </div>
80- ` ;
81-
82- commitElem . insertAdjacentHTML ( 'afterend' , html ) ;
83- } else {
84- const defaultHtml = `
85- <div role="gridcell" class="mr-1 eg-download" style="width: 90px;"></div>
86- ` ;
46+ setTimeout ( function ( ) {
47+ commonUtil . removePrevInstancesOf ( '.eg-download' ) ; // remove before adding new ones
8748
88- commitElem . insertAdjacentHTML ( 'afterend' , defaultHtml ) ;
89- }
49+ const containerItems = document . querySelectorAll (
50+ '.js-navigation-container.js-active-navigation-container .js-navigation-item'
51+ ) ;
9052
91- actualDataIndex ++ ;
92- }
93- }
94- } , 1000 ) ;
95-
96- return ;
97- }
53+ let actualDataIndex = 0 ;
9854
99- commonUtil . removePrevInstancesOf ( '.download' ) ; // remove before adding new ones
55+ for ( var i = 0 ; i < containerItems . length ; i ++ ) {
56+ const commitElem = containerItems [ i ] . querySelector ( '.commit-message' ) ;
10057
101- let uptree = document . querySelectorAll ( 'tr.up-tree > td' ) ;
58+ if ( commitElem ) {
59+ containerItems [ i ] . querySelector ( 'div:nth-of-type(2)' ) . classList . remove ( 'col-md-2' , 'mr-3' ) ;
60+ containerItems [ i ] . querySelector ( 'div:nth-of-type(2)' ) . classList . add ( 'col-md-1' , 'mr-2' ) ;
10261
103- if ( uptree && uptree [ 3 ] ) {
104- uptree [ 3 ] . insertAdjacentHTML ( 'afterend' , '<td class="download"></td>' ) ;
105- }
62+ if ( data [ actualDataIndex ] . type === 'file' ) {
63+ let formattedFileSize = commonUtil . getFileSizeAndUnit ( data [ actualDataIndex ] ) ;
10664
107- let elems = document . querySelectorAll ( 'tr.js-navigation-item > td.age' ) ;
65+ let html = `
66+ <div role="gridcell" class="mr-1 text-gray-light eg-download" style="width: 95px;">
67+ <span class="css-truncate css-truncate-target d-block">
68+ <span style="margin-right: 5px;">
69+ ${ formattedFileSize }
70+ </span>
71+ <a style="float: right" href="${ data [ actualDataIndex ] . download_url } " title="(Alt/Option/Ctrl + Click) to download File" aria-label="(Alt/Option/Ctrl + Click) to download File" class="tooltipped tooltipped-s"
72+ download="${ data [ actualDataIndex ] . name } ">
73+ <svg class="octicon octicon-cloud-download" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16">
74+ <path d="M9 12h2l-3 3-3-3h2V7h2v5zm3-8c0-.44-.91-3-4.5-3C5.08 1 3 2.92 3 5 1.02 5 0 6.52 0 8c0 1.53 1 3 3 3h3V9.7H3C1.38 9.7 1.3 8.28 1.3 8c0-.17.05-1.7 1.7-1.7h1.3V5c0-1.39 1.56-2.7 3.2-2.7 2.55 0 3.13 1.55 3.2 1.8v1.2H12c.81 0 2.7.22 2.7 2.2 0 2.09-2.25 2.2-2.7 2.2h-2V11h2c2.08 0 4-1.16 4-3.5C16 5.06 14.08 4 12 4z"></path>
75+ </svg>
76+ </a>
77+ </span>
78+ </div>
79+ ` ;
80+
81+ commitElem . insertAdjacentHTML ( 'afterend' , html ) ;
82+ } else {
83+ const defaultHtml = `
84+ <div role="gridcell" class="mr-1 eg-download" style="width: 90px;"></div>
85+ ` ;
86+
87+ commitElem . insertAdjacentHTML ( 'afterend' , defaultHtml ) ;
88+ }
10889
109- for ( let i = 0 ; i < elems . length ; i ++ ) {
110- if ( data [ i ] . type === 'file' ) {
111- let formattedFileSize = commonUtil . getFileSizeAndUnit ( data [ i ] ) ;
112-
113- let html = `
114- <td class="download js-enhanced-github-download-btn" style="width: 20px;padding-right: 10px;color: #6a737d;text-align: right;white-space: nowrap;">
115- <span style="margin-right: 5px;">
116- ${ formattedFileSize }
117- </span>
118- <a href="${ data [ i ] . download_url } " title="(Alt/Option/Ctrl + Click) to download File" aria-label="(Alt/Option/Ctrl + Click) to download File" class="tooltipped tooltipped-nw"
119- download="${ data [ i ] . name } ">
120- <svg class="octicon octicon-cloud-download" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16">
121- <path d="M9 12h2l-3 3-3-3h2V7h2v5zm3-8c0-.44-.91-3-4.5-3C5.08 1 3 2.92 3 5 1.02 5 0 6.52 0 8c0 1.53 1 3 3 3h3V9.7H3C1.38 9.7 1.3 8.28 1.3 8c0-.17.05-1.7 1.7-1.7h1.3V5c0-1.39 1.56-2.7 3.2-2.7 2.55 0 3.13 1.55 3.2 1.8v1.2H12c.81 0 2.7.22 2.7 2.2 0 2.09-2.25 2.2-2.7 2.2h-2V11h2c2.08 0 4-1.16 4-3.5C16 5.06 14.08 4 12 4z"></path>
122- </svg>
123- </a>
124- </td>` ;
125- elems [ i ] . insertAdjacentHTML ( 'afterend' , html ) ;
126- } else {
127- elems [ i ] . insertAdjacentHTML ( 'afterend' , '<td class="download"></td>' ) ;
90+ actualDataIndex ++ ;
91+ }
12892 }
129- }
93+ } , 1000 ) ;
94+
95+ return ;
13096 }
13197} ;
13298
0 commit comments