lbtest

test

目前為 2025-01-05 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.cn-greasyfork.org/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);
            }
        });
    }

})();