Greasy Fork is available in English.
try to take over the world!
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.icu/scripts/522849/1515122/New%20Userscript.js
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 1.0
// @description try to take over the world!
// @author People starving to death
// @match *://*/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=zhipin.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
console.log('window.hideJobItem before definition', window.hideJobItem);
// 判断当前页面是否为列表页 /geek/job
const isListPage = window.location.href.includes("/geek/job");
// 处理列表页的逻辑
function processListPage() {
console.log("正在处理列表页...");
// 获取列表中的所有职位项
const jobListItems = document.querySelectorAll('.your-list-item-selector'); // 替换为你实际的列表项选择器
// 监听翻页操作
const nextPageButton = document.querySelector('.pagination-next');
if (nextPageButton) {
nextPageButton.addEventListener('click', function() {
console.log("翻页了,重新加载列表页面");
processListPage(); // 重新调用列表页的处理函数
});
}
// 监听 postMessage 事件,接收来自详情页的消息
window.addEventListener("message", function(event) {
if (event.data && event.data.type === "hideJobItem" && event.data.data) {
const nameText = event.data.data.nameText;
console.log(`接收到隐藏职位的事件: ${nameText}`);
jobListItems.forEach(function(item) {
if (item.textContent.includes(nameText)) {
item.style.display = 'none';
console.log(`在列表页隐藏职位项: ${nameText}`);
}
});
}
});
}
// 直接暴露的全局方法,可以供详情页调用
window.hideJobItem = function(nameText) {
console.log(`通过库函数在列表页隐藏职位项: ${nameText}`);
const jobListItems = document.querySelectorAll('ul.job-list-box > li'); // 替换为你实际的列表项选择器
jobListItems.forEach(function(item) {
if (item.textContent.includes(nameText)) {
item.style.display = 'none';
}
});
};
// 在页面加载完成后执行,确保元素都存在
window.addEventListener('load', function() {
if (isListPage) {
console.log("页面为列表页");
processListPage();
}
});
console.log('window.hideJobItem after definition', window.hideJobItem);
})();