Handshake Hide Jobs

Add a button to hide jobs on Handshake

当前为 2024-02-06 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Handshake Hide Jobs
// @namespace    https://github.com/bhackel
// @version      1.2
// @description  Add a button to hide jobs on Handshake
// @author       bhackel
// @match        https://*.joinhandshake.com/stu/postings*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=joinhandshake.com
// @grant        GM_setValue
// @grant        GM_getValue
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const savedHiddenJobIds = GM_getValue('hiddenJobIds', '[]');
    // Convert the retrieved string back to an array
    let hiddenJobIds = JSON.parse(savedHiddenJobIds);

    function addButtonToDivs() {
        const targetDiv = document.querySelector("#skip-to-content > div:nth-child(4) > div > div:nth-child(1) > div > div > form > div:nth-child(2) > div > div > div > div:nth-child(3) > div > div");

        const childrenArray = [...targetDiv.children]; // convert from nodelist to array

        childrenArray.forEach(div => {
            // Ignore spacing divs
            if (div.querySelectorAll('div').length <= 1) {
                return;
            }
            // Unique identifier for each job
            let jobId = div.children[0].id;
            if (div.style.display !== 'none' && hiddenJobIds.includes(jobId)) {
                console.log("Hiding previously hidden job " + jobId);
                div.style.display = 'none';
            }

            // Check if div already contains a button
            const existingButton = div.querySelector('.bhackel-button');

            if (!existingButton) {
                const newButton = document.createElement('button');
                newButton.textContent = 'Hide';
                newButton.classList.add('bhackel-button'); // Add the class 'bhackel-button'
                newButton.addEventListener('click', () => {
                    console.log("Hiding job " + jobId);
                    div.style.display = 'none';
                    hiddenJobIds.push(jobId);
                    // Attempt to click the job below this one
                    let nextJobDiv = div.nextElementSibling.nextElementSibling;
                    setTimeout(function() {
                        nextJobDiv?.children[0]?.click();
                    }, 500);
                });
                div?.children[0]?.appendChild(newButton);
            }
        });

        GM_setValue('hiddenJobIds', JSON.stringify(hiddenJobIds));

    }

    // Check for new divs and add buttons every 5 seconds (you can adjust the interval)
    setInterval(addButtonToDivs, 5000);

})();