MCPcopy Index your code
hub / github.com/XIU2/UserScript / removeLoginModal

Function removeLoginModal

Zhihu-Enhanced.user.js:1339–1351  ·  view source on GitHub ↗
(mutationsList, observer)

Source from the content-addressed store, hash-verified

1337// 移除登录弹窗
1338function removeLogin() {
1339 const removeLoginModal = (mutationsList, observer) => {
1340 for (const mutation of mutationsList) {
1341 for (const target of mutation.addedNodes) {
1342 if (target.nodeType != 1) return
1343 if (target.querySelector('.signFlowModal')) {
1344 let button = target.querySelector('.Button.Modal-closeButton.Button--plain');
1345 if (button) button.click();
1346 } else if (getXpath('//button[text()="立即登录/注册"]',target)) {
1347 target.remove();
1348 }
1349 }
1350 }
1351 };
1352
1353 // 未登录时才会监听并移除登录弹窗
1354 if(location.hostname === 'zhuanlan.zhihu.com') { // 如果是文章页

Callers

nothing calls this directly

Calls 1

getXpathFunction · 0.70

Tested by

no test coverage detected