MCPcopy Create free account
hub / github.com/ChinaGodMan/UserScripts / appendButtons

Function appendButtons

github-raw-file-plus/github-raw-file-plus.user.js:115–154  ·  view source on GitHub ↗
(fileList, isTable = false)

Source from the content-addressed store, hash-verified

113}, scanInterval * 1000)
114
115function appendButtons(fileList, isTable = false) {
116 let fileUrl = ''
117 let rawFileUrl = ''
118 for (let i = 0; i < fileList.length; i++) {
119 let file = fileList[i]
120
121 if (file.classList.contains('cp-btn-rdy')) continue
122
123 file.classList.add('cp-btn-rdy')
124
125 if (!isTable) {
126 if (
127 file.classList.contains('sr-only') ||
128 file.childElementCount !== 4
129 ) continue
130
131 fileUrl = file.querySelector('div:nth-child(2) .js-navigation-open')
132 .href
133 } else {
134 if (i === 0) continue
135
136 if (
137 file.classList.contains('sr-only')
138 ) continue
139
140
141 fileUrl = file.querySelector('a')
142 .href
143 file = file.querySelector('td:nth-child(4) > div')
144 }
145 //alert(fileUrl)
146 // Dont add button if its a folder
147 if (!fileUrl.includes('/blob/')) continue
148
149 rawFileUrl = fileUrl.replace('/blob/', '/raw/')
150 file.style = 'display: flex; justify-content: flex-end;'
151 file.append(creatyCopyButton(rawFileUrl))
152 file.append(creatyDownButton(rawFileUrl))
153 }
154}
155
156function creatyCopyButton(copyText) {
157 const copy2clipboard = `

Callers 1

Calls 2

creatyCopyButtonFunction · 0.85
creatyDownButtonFunction · 0.85

Tested by

no test coverage detected