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

Function blockUsers_button_del

Zhihu-Enhanced.user.js:825–843  ·  view source on GitHub ↗
(name, userid, reload)

Source from the content-addressed store, hash-verified

823
824 // 屏蔽用户按钮绑定事件(删除)
825 function blockUsers_button_del(name, userid, reload) {
826 if (!name || !userid) return
827 let users = menu_value('menu_customBlockUsers'), // 读取屏蔽列表
828 index = users.indexOf(name);
829 if (index > -1) {
830 users.splice(index, 1); // 移除用户名
831 GM_setValue('menu_customBlockUsers', users); // 写入屏蔽列表
832 // 移除知乎自带的黑名单
833 GM_xmlhttpRequest({url: `https://www.zhihu.com/api/v4/members/${userid}/actions/block`,method: 'DELETE',timeout: 2000});
834 // 是否刷新本页
835 if (reload) {
836 setTimeout(function(){location.reload()}, 200); // 刷新网页,延迟 200 毫秒,避免知乎反应慢~
837 } else {
838 GM_notification({text: `该用户已取消屏蔽啦~\n刷新网页后生效~`, timeout: 3000});
839 }
840 } else {
841 GM_notification({text: `没有在屏蔽列表中找到该用户...`, timeout: 3000});
842 }
843 }
844}
845
846

Callers 2

callbackFunction · 0.85
blockUsers_button_peopleFunction · 0.85

Calls 1

menu_valueFunction · 0.70

Tested by

no test coverage detected