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

Function callback

V2ex-Enhanced.user.js:372–389  ·  view source on GitHub ↗
(mutationsList, observer)

Source from the content-addressed store, hash-verified

370 });
371
372 const callback = (mutationsList, observer) => {
373 for (const mutation of mutationsList) {
374 for (const target of mutation.addedNodes) {
375 if (target.nodeType != 1) return
376 if (target.tagName === 'A') {
377 if (target.onclick || target.href.slice(0,4) != 'http' || target.href.indexOf('#;') > -1 || target.href.indexOf('night/toggle') > -1 || target.href.indexOf('/favorite') > -1) {
378 target.target = '_self'
379 }
380 } else {
381 document.querySelectorAll('a').forEach(function (_this) {
382 if (_this.onclick || _this.href.slice(0,4) != 'http' || _this.href.indexOf('#;') > -1 || _this.href.indexOf('night/toggle') > -1 || _this.href.indexOf('/favorite') > -1) {
383 _this.target = '_self'
384 }
385 });
386 }
387 }
388 }
389 };
390 const observer = new MutationObserver(callback);
391 observer.observe(document, { childList: true, subtree: true });
392 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected