Nowpick replace 999+ with actual deliverNum

Request a specific URL, replace 999+ with actual data from the response, and show job info in a toast with delay

目前為 2024-08-18 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Nowpick replace 999+ with actual deliverNum
// @namespace    http://tampermonkey.net/
// @version      1.0.2
// @license      MIT
// @description  Request a specific URL, replace 999+ with actual data from the response, and show job info in a toast with delay
// @author       aspen138
// @match        *://nowpick.nowcoder.com/w/hrconsole/job-manage*
// @grant        GM_xmlhttpRequest
// @grant        GM_addStyle
// @icon         https://aowuucdn.oss-cn-beijing.aliyuncs.com/nowcoder.png
// @require      https://update.gf.qytechs.cn/scripts/462234/1322684/Message.js
// ==/UserScript==



// key: "getDeliverNum",
// value: function(t) {
//     if (1 === t.showStatus)
//         return "- -";
//     var e = t.inviteSuccessCnt + t.initiativeDeliverCnt;
//     return e > 999 ? "999+" : e
// }



(function() {
    'use strict';

    window.QMSG_GLOBALS = {
        DEFAULTS: {
            showClose: true,
            autoClose: false,
            timeout: 3600 * 1000 // ms
        }
    }

    const name = "JobUpdater";

    function toast(s, error = false) {
        if (error) {
            Qmsg.error(`[${name}] ${s}`);
            console.error(`[${name}] ${s}`);
        } else {
            Qmsg.success(`[${name}] ${s}`);
            console.log(`[${name}] ${s}`);
        }
    }

    // Function to show a toast message
    function showToast(message) {
        toast(" " + message, false); // Display
    }

    // Function to escape special characters in CSS selectors
    function escapeCSSSelector(selector) {
        return selector.replace(/([!"#$%&'()*+,.\/:;<=>?@[\\\]^`{|}~])/g, '\\$1');
    }

    // Function to replace the '999+' value with actual data
    function replaceValues(jobName, unProcessCount) {
        const jobTitleElements = document.querySelectorAll('.job-title-name');
        jobTitleElements.forEach(el => {
            if (el.textContent.trim() === jobName) {
                //console.log("equal! el.textContent.trim()=",el.textContent.trim());
                const jobInfoParent = el.closest('.job-info').parentElement.parentElement;
                //console.log("jobInfoParent=",jobInfoParent);
                const unProcessElement = jobInfoParent.querySelector('.tw-font-semibold');
                //console.log("unProcessElement=",unProcessElement);
                //console.log("unProcessElement.textContent.trim()=",unProcessElement.textContent.trim());
                if (unProcessElement && unProcessElement.textContent.trim() === '999+') {
                    unProcessElement.textContent = unProcessCount;
                    showToast(`Updated job "${jobName}" with deliverNum: ${unProcessCount}`);
                }
            }
        });
    }

    // Function to delay the update
    function delayUpdate(summaryDetailList) {
        setTimeout(() => {
            summaryDetailList.forEach(job => {
                var deliverNum=job.unProcessCount+job.successCount+job.failCount+job.unDetermined+job.writtenInterviewCount;
                replaceValues(job.jobName, deliverNum);
            });
        }, 5000); // 5 seconds delay
    }

    // Capture the URL and make the request
    GM_xmlhttpRequest({
        method: "GET",
        url: "https://nowpick.nowcoder.com/h/resume-deliver/summary",
        onload: function(response) {
            //console.log("response=",response);
            if (response.status === 200) {
                try {
                    const jsonResponse = JSON.parse(response.responseText);
                    if (jsonResponse.data && jsonResponse.data.summaryDetailList) {
                        const summaryDetailList = jsonResponse.data.summaryDetailList;
                        //console.log("summaryDetailList=",summaryDetailList);
                        delayUpdate(summaryDetailList);
                    } else {
                        showToast("Unexpected response format");
                    }
                } catch (e) {
                    showToast("Failed to parse JSON response");
                }
            } else {
                showToast("Error: " + response.statusText);
            }
        },
        onerror: function(response) {
            showToast("Request failed: " + response.statusText);
        }
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址