Greasy Fork

lbtest

test

目前为 2025-01-05 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.greasyfork.cloud/scripts/522876/1515248/lbtest.js

(function() {
    'use strict';

    const listPageChannel = new BroadcastChannel('jobDetailsChannel'); // 创建频道
    let listPageDocument = document; // 列表页的 document

    console.log('List page document:', listPageDocument);

    // 监听来自其他页面的消息
    listPageChannel.addEventListener('message', function(event) {
        if (event.data.type === 'hideJobItem') {
            const { nameText, salary, bossInfo } = event.data.data;
            console.log('Received message in list page:', nameText, salary, bossInfo);
            hideJobItems(nameText, salary, bossInfo);
        }
    });

    // 隐藏指定职位
    function hideJobItems(nameText, salary, bossInfo) {
        const jobListItems = listPageDocument.querySelectorAll('.your-list-item-selector'); // 替换为实际的选择器
        jobListItems.forEach(function(item) {
            const itemText = item.textContent;
            const matchesName = nameText === '' || itemText.includes(nameText);
            const matchesSalary = salary === '' || itemText.includes(salary);
            const matchesBossInfo = bossInfo === '' || itemText.includes(bossInfo);
            if (matchesName && matchesSalary && matchesBossInfo) {
                item.style.display = 'none';
                console.log('Hiding job item:', item);
            }
        });
    }

})();