boss直聘去除已沟通脚本

自用。boss直聘滚动新增的时候去除已经沟通的候选人。这不会改变这一次查询增加的数据,极端情况会导致一轮跟新完全不增加视图。凑合着用吧。

// ==UserScript==
// @name         boss直聘去除已沟通脚本
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  自用。boss直聘滚动新增的时候去除已经沟通的候选人。这不会改变这一次查询增加的数据,极端情况会导致一轮跟新完全不增加视图。凑合着用吧。
// @author       hilshire
// @match        *://www.zhipin.com/chat/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Options for the observer (which mutations to observe)
    var config = { attributes: true, childList: true, subtree: true };

    // Callback function to execute when mutations are observed
    var callback = function(mutationsList) {
        for(var mutation of mutationsList) {
            if (mutation.type == 'childList' && mutation.addedNodes.length !== 0) {
                filterCandidate()
            }
            else if (mutation.type == 'attributes') {
                // console.log('The ' + mutation.attributeName + ' attribute was modified.');
            }
        }
    };

    // Create an observer instance linked to the callback function
    var observer = new MutationObserver(callback);

    // Start observing the target node for configured mutations
    observer.observe(document.querySelector('.sec-content.candidate-card'), config);

    filterCandidate()

    function filterCandidate() {
        var candidates = Array.from(document.querySelector('.sec-content.candidate-card').querySelectorAll('li[data-uid]'))

        if(!candidates || candidates.length === 0) return

        candidates.filter(i => i.querySelector('.btn-continue')).forEach(j => (j.style.display = 'none'))
    }

})();