-
Notifications
You must be signed in to change notification settings - Fork 7
/
block-hunter.user.js
66 lines (60 loc) · 2.22 KB
/
block-hunter.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// ==UserScript==
// @name 屏蔽 Boss 直聘猎头岗位
// @namespace http://tampermonkey.net/
// @version 0.0.1
// @description boos 上现在猎头的的岗位太多了,直接屏蔽所有猎头的岗位
// @author YuTengjing
// @supportURL https://github.com/tjx666/user-scripts/issues
// @homepage https://github.com/tjx666/user-scripts
// @match https://www.zhipin.com/web/geek/job*
// @icon https://www.google.com/s2/favicons?sz=64&domain=zhipin.com
// @grant none
// ==/UserScript==
(function () {
'use strict';
async function sleep(ms) {
return new Promise((resolve) => {
setTimeout(() => resolve(), ms);
});
}
async function waitElement(selector, delay = 50) {
let element = document.querySelector(selector);
while (element === null) {
await sleep(delay);
element = document.querySelector(selector);
}
return element;
}
const blockTags = new Set(['猎头', '代招']);
async function update() {
await waitElement('.job-list-box');
const jobCards = document.querySelectorAll('.job-card-wrapper');
jobCards.forEach((card) => {
const hunterIcon = card.querySelector('img.job-tag-icon');
if (blockTags.has(hunterIcon?.alt)) {
card.remove();
}
});
}
(async function main() {
await update();
const searchResultDiv = document.querySelector('.search-job-result');
if (searchResultDiv) {
const observer = new MutationObserver((mutationsList) => {
for (const mutation of mutationsList) {
if (mutation.type === 'childList') {
const firstAddNode = mutation.addedNodes[0];
if (
firstAddNode &&
firstAddNode.nodeName === 'UL' &&
firstAddNode.matches('.job-list-box')
) {
update();
}
}
}
});
observer.observe(searchResultDiv, { childList: true });
}
})();
})();