| 295 | |
| 296 | // Git Clone |
| 297 | function addGitClone(target) { |
| 298 | let html = target.querySelector('input[value^="https:"]:not([title])');if (!html) return |
| 299 | let href_split = html.value.split(location.host)[1], |
| 300 | html_parent = '<div style="margin-top: 4px;" class="XIU2-GC ' + html.parentElement.className + '">', |
| 301 | url = '', _html = '', _gitClone = ''; |
| 302 | if (html.nextElementSibling) html.nextElementSibling.hidden = true; // 隐藏右侧复制按钮(考虑到能直接点击复制,就不再重复实现复制按钮事件了) |
| 303 | if (html.parentElement.nextElementSibling.tagName === 'P'){ |
| 304 | html.parentElement.nextElementSibling.textContent += ' (↑点击文字自动复制)' |
| 305 | } |
| 306 | if (GM_getValue('menu_gitClone')) {_gitClone='git clone '; html.value = _gitClone + html.value; html.setAttribute('value', html.value);} |
| 307 | // 克隆原 Git Clone 元素 |
| 308 | let html_clone = html.cloneNode(true); |
| 309 | for (let i=0;i<clone_url.length;i++) { |
| 310 | if (clone_url[i][0] === 'https://gitclone.com') { |
| 311 | url = clone_url[i][0] + '/github.com' + href_split |
| 312 | } else { |
| 313 | url = clone_url[i][0] + href_split |
| 314 | } |
| 315 | html_clone.title = `${url}\n\n${clone_url[i][2].replaceAll(' ','\n')}\n\n提示:点击文字可直接复制` |
| 316 | html_clone.setAttribute('value', _gitClone + url) |
| 317 | _html += html_parent + html_clone.outerHTML + '</div>' |
| 318 | } |
| 319 | html.parentElement.insertAdjacentHTML('afterend', _html); |
| 320 | if (html.parentElement.parentElement.className.indexOf('XIU2-GCP') === -1){ |
| 321 | html.parentElement.parentElement.classList.add('XIU2-GCP') |
| 322 | html.parentElement.parentElement.addEventListener('click', (e)=>{if (e.target.tagName === 'INPUT') {GM_setClipboard(e.target.value);}}) |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | |
| 327 | // Git Clone SSH |