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

Function appendScriptsInfo

script-finder-plus/script-finder-plus.user.js:291–353  ·  view source on GitHub ↗
(scriptsInfo)

Source from the content-addressed store, hash-verified

289
290 // 插入脚本
291 function appendScriptsInfo(scriptsInfo) {
292 const infoList = document.querySelector('.sf-info-list')
293 if (scriptsInfo === errorMessage) {
294 // infoList.innerHTML = errorMessage;
295 const loadMoreButton = document.querySelector('.sf-load-more')
296 loadMoreButton.disabled = true
297 loadMoreButton.textContent = translate('AllScriptsLoaded')
298 loadMoreButton.innerHTML = errorMessage
299 } else {
300 for (var i = 0; i < scriptsInfo.length; i++) {
301 var script = scriptsInfo[i]
302 var listItem = document.createElement('li')
303 listItem.className = 'sf-info-item'
304
305 var scriptContainer = document.createElement('div')
306 scriptContainer.className = 'sf-script-container'
307
308 var nameElement = document.createElement('a')
309 nameElement.className = 'sf-mscript-link'
310 nameElement.innerText = script.name
311 nameElement.href = script.url
312 nameElement.target = '_blank'
313
314 var descriptionElement = document.createElement('p')
315 descriptionElement.className = 'sf-script-description-finder'
316 descriptionElement.innerHTML = script.description
317
318 var detailsContainer = document.createElement('div')
319 detailsContainer.className = 'sf-details-container'
320
321 // 创建一键安装按钮
322 var installButton = document.createElement('a')
323 installButton.className = 'sf-install-button'
324 installButton.innerText = `Install ${script.version}`
325 installButton.href = `https://greasyfork.org/scripts/${script.id}/code/script.user.js`
326
327 const details = [
328 { key: translate('Author'), value: script.author },
329 { key: translate('Installs'), value: script.installs },
330 { key: translate('DailyInstalls'), value: script.dailyInstalls },
331 { key: translate('Created'), value: script.createDate },
332 { key: translate('Updated'), value: script.updateDate },
333 { key: translate('Rating'), value: script.ratingScore }
334 ]
335
336 for (let i = 0; i < details.length; i++) {
337 const spanElement = document.createElement('span')
338 spanElement.className = 'sf-script-details'
339 spanElement.innerText = `${details[i].key}:\n${details[i].value}`
340 detailsContainer.appendChild(spanElement)
341 }
342
343 scriptContainer.appendChild(nameElement)
344 scriptContainer.appendChild(descriptionElement)
345 scriptContainer.appendChild(detailsContainer)
346 scriptContainer.appendChild(installButton)
347
348 listItem.appendChild(scriptContainer)

Callers 1

getScriptsInfoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected