MCPcopy Create free account
hub / github.com/XIU2/UserScript / addGitCloneSSH

Function addGitCloneSSH

GithubEnhanced-High-Speed-Download.user.js:328–351  ·  view source on GitHub ↗
(target)

Source from the content-addressed store, hash-verified

326
327 // Git Clone SSH
328 function addGitCloneSSH(target) {
329 let html = target.querySelector('input[value^="git@"]:not([title])');if (!html) return
330 let href_split = html.value.split(':')[1],
331 html_parent = '<div style="margin-top: 4px;" class="XIU2-GCS ' + html.parentElement.className + '">',
332 url = '', _html = '', _gitClone = '';
333 html.nextElementSibling.hidden = true; // 隐藏右侧复制按钮(考虑到能直接点击复制,就不再重复实现复制按钮事件了)
334 if (html.parentElement.nextElementSibling.tagName === 'P'){
335 html.parentElement.nextElementSibling.textContent += ' (↑点击自动复制)'
336 }
337 if (GM_getValue('menu_gitClone')) {_gitClone='git clone '; html.value = _gitClone + html.value; html.setAttribute('value', html.value);}
338 // 克隆原 Git Clone SSH 元素
339 let html_clone = html.cloneNode(true);
340 for (let i=0;i<clone_ssh_url.length;i++) {
341 url = clone_ssh_url[i][0] + href_split
342 html_clone.title = `${url}\n\n${clone_ssh_url[i][2].replaceAll('&#10;','\n')}\n\n提示:点击文字可直接复制`
343 html_clone.setAttribute('value', _gitClone + url)
344 _html += html_parent + html_clone.outerHTML + '</div>'
345 }
346 html.parentElement.insertAdjacentHTML('afterend', _html);
347 if (html.parentElement.parentElement.className.indexOf('XIU2-GCP') === -1){
348 html.parentElement.parentElement.classList.add('XIU2-GCP')
349 html.parentElement.parentElement.addEventListener('click', (e)=>{if (e.target.tagName === 'INPUT') {GM_setClipboard(e.target.value);}})
350 }
351 }
352
353
354 // Raw

Callers 1

callbackFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected