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

Function callback

GithubEnhanced-High-Speed-Download.user.js:184–213  ·  view source on GitHub ↗
(mutationsList, observer)

Source from the content-addressed store, hash-verified

182
183 // Github Git Clone/SSH、Release、Download ZIP 改版为动态加载文件列表,因此需要监控网页元素变化
184 const callback = (mutationsList, observer) => {
185 if (location.pathname.indexOf('/releases') > -1) { // Release
186 for (const mutation of mutationsList) {
187 for (const target of mutation.addedNodes) {
188 if (target.nodeType !== 1) return
189 if (target.tagName === 'DIV' && target.dataset.viewComponent === 'true' && target.classList[0] === 'Box') addRelease();
190 }
191 }
192 } else if (document.querySelector('#repository-container-header:not([hidden])')) { // 项目首页
193 for (const mutation of mutationsList) {
194 for (const target of mutation.addedNodes) {
195 if (target.nodeType !== 1) return
196 if (target.tagName === 'DIV' && target.parentElement && target.parentElement.id === '__primerPortalRoot__') {
197 addGitClone(target);
198 addGitCloneSSH(target);
199 addDownloadZIP(target);
200 //setTimeout(()=>{addDownloadZIP(target)}, 300);
201 } else if (target.tagName === 'DIV' && target.className.indexOf('LocalTab-module__') != -1) {
202 if (target.querySelector('input[value^="https:"]')) {
203 addGitCloneClear('.XIU2-GCS'); addGitClone(target);
204 } else if (target.querySelector('input[value^="git@"]')) {
205 addGitCloneClear('.XIU2-GC'); addGitCloneSSH(target);
206 } else if (target.querySelector('input[value^="gh "]')) {
207 addGitCloneClear('.XIU2-GC, .XIU2-GCS');
208 }
209 }
210 }
211 }
212 }
213 };
214 const observer = new MutationObserver(callback);
215 observer.observe(document, { childList: true, subtree: true });
216

Callers

nothing calls this directly

Calls 5

addReleaseFunction · 0.85
addGitCloneFunction · 0.85
addGitCloneSSHFunction · 0.85
addDownloadZIPFunction · 0.85
addGitCloneClearFunction · 0.85

Tested by

no test coverage detected