// ==UserScript==
// @name BOSS 直聘 跨境黑名单
// @namespace https://github.com/iibeibei
// @version 0.2.9
// @description 可以在 BOSS 直聘、智联招聘、前程无忧 上 显示 若比邻的 黑名单,应 Facebook 群友要求,分享一下 祝大家早日找到好工作
// @author Beibei
// @license GPLv3
// @match https://*.zhipin.com/*
// @match https://*.zhaopin.com/*
// @match https://*.51job.com/*
// @connect kjrate.com
// @connect kjxb.org
// @grant GM_info
// @grant GM_xmlhttpRequest
// @grant GM_getResourceText
// @grant GM_download
// @grant GM_addStyle
// @grant GM_openInTab
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_registerMenuCommand
// @grant GM_unregisterMenuCommand
// @grant GM_notification
// @grant unsafeWindow
// @compatible firefox Tampermonkey
// @compatible chrome Tampermonkey
// @compatible edge Tampermonkey
// @require https://unpkg.com/jquery
// @require https://unpkg.com/moment
// @require https://unpkg.com/sweetalert2
// @require https://cdn.jsdelivr.net/npm/dayjs@1/dayjs.min.js
// @require https://update.greasyfork.org/scripts/448161/1362731/Beibeijs.js
// @resource element-plus https://unpkg.com/element-plus/dist/index.css
// @note 0.2.9 新加 BOSS直聘 刨了小红书tzy大佬的, 添加岗位最近编辑时间
// @note 0.2.8 修复 BOSS直聘 更新新的若比邻网站
// @note 0.2.7 修复 BOSS直聘 职位页面错误显示的问题
// @note 0.2.6 修复 BOSS直聘 所有页面都在新标签打开
// @note 0.2.0 修复 BOSS直聘 聊天页改版不显示的问题
// @note 0.1.5 修复 BOSS直聘 搜索页改版不显示的问题
// @note 0.1.4 修复 BOSS直聘 详情页改版不显示的问题
// ==/UserScript==
// append() - 在被选元素的结尾插入内容(内容的结尾,比如说有个a标签,则是在</a>这个标签之前添加东西) <a> [append]</a>
// prepend() - 在被选元素的开头插入内容(内容的开始,比如说有个a标签,则是在<a>这个标签之后添加东西) <a>[prepend] </a>
// after() - 在被选元素之后插入内容(元素的结尾,比如说有个a标签,则是在</a>这个标签之后添加东西) <a> </a>[after]
// before() - 在被选元素之前插入内容(内容的开始,比如说有个a标签,则是在<a>这个标签之前添加东西) [before]<a> </a>
// 初始化脚本
var version_url = 'https://greasyfork.org/zh-CN/scripts/448162';
var menu_ALL = [['menu_amazon', 'Amazon', 'Amazon', true]];
// initializationScript()
loadMenu(menu_ALL, version_url);
// BOSS 直聘
waitForKeyElements('.company-info > h3 > a', 'zhipin.com', ['/web/geek'], false, false, 'node.after($(insert_html))', actionFunction);
waitForKeyElements('.level-list > .company-name', 'zhipin.com', ['/job_detail'], false, false, 'node.append($(insert_html))', actionFunction);
waitForKeyElements('a[ka="job-detail-company_custompage"]', 'zhipin.com', ['/job_detail'], false, false, 'node.append($(insert_html))', actionFunction);
waitForKeyElements('.base-info.fl > span:nth-child(2)', 'zhipin.com', ['/web/geek'], false, false, 'node.append($(insert_html))', actionFunction);
waitForKeyElements('.name-box > span:nth-child(2)', 'zhipin.com', ['/web/geek'], false, false, 'node.append($(insert_html))', actionFunction);
waitForKeyElements('.info-primary > .info > .name', 'zhipin.com', ['/gongsi'], false, false, 'node.append($(insert_html))', actionFunction);
waitForKeyElements('.business-detail-name', 'zhipin.com', ['/gongsi'], false, false, 'node.append($(insert_html))', actionFunction);
// 智联招聘
waitForKeyElements('.iteminfo__line1__compname__name', 'zhaopin.com', ['/'], false, false, 'node.after($(insert_html))', actionFunction);
waitForKeyElements('.company__title', 'zhaopin.com', ['/'], false, false, 'node.after($(insert_html))', actionFunction);
waitForKeyElements('.base-info__title > H1', 'zhaopin.com', ['/companydetail'], false, false, 'node.append($(insert_html))', actionFunction);
// 全程无忧
waitForKeyElements('.cname.at', '51job.com', ['/pc/search'], false, false, 'node.prepend($(insert_html))', actionFunction);
waitForKeyElements('.compName > a', '51job.com', ['/pc/my/myjob'], false, false, 'node.prepend($(insert_html))', actionFunction);
waitForKeyElements('.tHCopName > H1', '51job.com', ['/all'], false, false, 'node.append($(insert_html))', actionFunction);
waitForKeyElements('.com_name > p', '51job.com', ['/'], false, false, 'node.append($(insert_html))', actionFunction);
function actionFunction(node, selector_txt, active_host, active_url, js_code) {
if (selector_txt == '.company-info > h3 > a') {
parent_ka = node.parent().parent().parent().parent().parent().attr('ka');
parent_id = parent_ka.replace('search_list_', '');
data_list = JSON.parse(boss_joblist_res);
job_list = data_list?.zpData?.jobList;
job_list.forEach((item) => {
const { itemId, lastModifyTime } = item;
if (parent_id == itemId) {
time = dayjs(lastModifyTime).format('YYYY-MM-DD HH:mm:ss');
parent_div = `<div class="__boss_time_tag" style="position: absolute;right: 0;top: 0;background: rgba(229, 248, 248); \
color: #00a6a7;padding: 0 8px;font-size: 14px;border-radius: 0 0 0 4px;">编辑: ${time}</div>`;
$(`li[ka="${parent_ka}"]`).append($(parent_div));
}
});
// parent_div = `<div class="__zhipin_time_tag" style="position: absolute;right: 0;top: 0;background: #426eff; \
// color: white;padding: 0 8px;font-size: 14px;border-radius: 0 0 0 4px;">最近编辑:${time}</div>`;
}
if (GM_getValue('menu_amazon')) {
(async () => {
var node_class = node.attr('class');
if (node_class == undefined || (node_class.indexOf('beibei') == -1 && node_class.indexOf('base-title') == -1)) {
var company_replace = ['\n', '\r', '...', '公司名称', '企业名称:'];
var company_name = node.text();
for (x in company_replace) {
company_name = company_name.replace(company_replace[x], '').trim();
}
var blacklist_search = `https://kjxb.org/?s=${company_name}&post_type=question`;
// var blacklist_search = `https://kjrate.com/?s=${company_name}&post_type=question`;
var response = await makeGetRequest(blacklist_search);
var response_text = $(response.responseText);
var hyperlink = response_text.find('.ap-questions-hyperlink').attr('href');
var result = hyperlink == undefined ? ['#00F', blacklist_search, '去搜索一下'] : ['#F00', hyperlink, '若比邻黑名单'];
var insert_html = `<a class="beibei" target="_blank" style="color:${result[0]}" href='${result[1]}'>  ${result[2]}  </a>`;
eval(js_code);
}
})();
}
}
var boss_joblist_res = '';
const xhrOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function () {
const xhr = this;
if (arguments[1].indexOf('wapi/zpgeek/search/joblist.json') > -1) {
const getter = Object.getOwnPropertyDescriptor(XMLHttpRequest.prototype, 'responseText').get;
Object.defineProperty(xhr, 'responseText', {
get: () => {
let result = getter.call(xhr);
boss_joblist_res = result;
return result;
},
});
}
return xhrOpen.apply(xhr, arguments);
};