// ==UserScript== // @name 高级求职助手/招聘网站助手,支持前程无忧、智联招聘、BOSS直聘、拉钩、猎聘 // @namespace https://github.com/qq943260285 // @version 1.1 // @description 1.快捷添加企业黑名单;2.支持正则表达式黑名单;3.支持前程无忧、智联招聘、BOSS直聘、拉钩、猎聘;4.各大网站黑名单数据连通。 // @author 小宇专属(943260285@qq.com) // @license GPL-3.0-only // @icon https://qq943260285.github.io/favicon.png // @create 2019-3-25 // @lastmodified 2019-3-25 // @home-url https://greasyfork.org/zh-TW/scripts/380848 // @supportURL https://github.com/qq943260285/tampermonkey-recruitment-tool.git // @feedback-url https://github.com/qq943260285/tampermonkey-recruitment-tool.git // @note 2019.3.25-V0.1 初始化项目添加黑名单功能,后续视情况添加功能 // @match *://search.51job.com/* // @match *://sou.zhaopin.com/* // @match *://www.zhipin.com/* // @match *://www.lagou.com/* // @match *://www.liepin.com/* // @require https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js // @grant GM_getValue // @grant GM.getValue // @grant GM_setValue // @grant GM.setValue // @grant GM_addStyle // @downloadURL none // ==/UserScript== (function () { 'use strict'; let toolSize = 50; let positionLeft = true; let isExpand = true; let body = $('body'); body.before(``) body.before(``); let isMobile = false, mousedownPosition = {x: 0, y: 0}, toolPosition = {x: 0, y: 0}; let toolRegion = $('
').mousedown(function () { toolRegion.css('pointer-events', 'auto'); }).mouseup(function () { isMobile = false; toolRegion.css('pointer-events', 'none'); }).mousemove(function (e) { if (isMobile) { var mouseX = e.originalEvent.x || e.originalEvent.layerX || 0; var mouseY = e.originalEvent.y || e.originalEvent.layerY || 0; var Y = tool.position().top; var X = tool.position().left; var winH = $(window).height(); var winW = $(window).width(); toolPosition.x = X; toolPosition.y = Y; let left = X + mouseX - mousedownPosition.x; let bottom = winH - toolSize - Y - mouseY + mousedownPosition.y; tool.css({ "left": (left < 0 ? 0 : ((left + toolSize) > winW) ? (winW - toolSize) : left) + "px", "bottom": (bottom < 0 ? 0 : ((bottom + toolSize) > winH) ? (winH - toolSize) : bottom) + "px" }); if (positionLeft === ((winW / 2) < (X + toolSize / 2))) { menu.css({ "width": (menuItems.length * 50 + 20) + "px", "left": ((winW / 2) < (X + toolSize / 2) ? (-1 * (menuItems.length * 50 + 20)) : 50) + "px" }); menuItems.reverse(); createMenu(); positionLeft = !positionLeft; } mousedownPosition.x = mouseX; mousedownPosition.y = mouseY; } }).css('pointer-events', 'none'); let tool = $(`
`).mouseleave(function () { menu.hide(70); }).mouseenter(function () { menu.show(70); }).mousedown(function (e) { isMobile = true; isExpand = true; toolRegion.css('pointer-events', 'auto'); mousedownPosition.x = e.originalEvent.x || e.originalEvent.layerX || 0; mousedownPosition.y = e.originalEvent.y || e.originalEvent.layerY || 0; }).mousemove(function () { isExpand = false; }).click(function () { if (isExpand) { menu.toggle(); } }).css({"left": "10px", "bottom": "10px"}); let menuItems = [{ ico: "fa-eye-slash", title: "黑名单管理", callback: function () { let div = $(`
`); $.each(blacklistList, function (index, item) { div.append($(`
` + item + `
`).append($(``).click(function () { dleDlacklistName($(this).attr('item-name')); $(this).closest('.xyzs-enterprise-item').remove(); }))) }); showWin("黑名单管理", div); } }, { ico: "fa-podcast", title: "作者博客", callback: function () { window.open("https://qq943260285.github.io"); } }, { ico: "fa-github", title: "github开源", callback: function () { window.open('https://github.com/qq943260285/tampermonkey-recruitment-tool.git'); } },]; var menu = $(``).css({"width": (menuItems.length * 50 + 20) + "px"}); var createMenu = function () { menu.empty(); for (let i = 0; i < menuItems.length; i++) { menu.append($('
').click(function () { menuItems[i].callback(); })); } }; createMenu(); tool.append(menu); toolRegion.append(tool); body.append(toolRegion); let win = $(`
标题
内容
`).hide(); win.find('.xyzs-modal-close').click(function () { win.hide(); toolRegion.css({"background-color": ""}); }); function showWin(t, div) { toolRegion.css({'pointer-events': 'auto', "background-color": "rgba(55,55,55,.6)"}); win.show(500); win.find(".xyzs-modal-header-inner").text(t); win.find('.xyzs-modal-body').empty().append(div); } toolRegion.append(win); let blacklistKey = 'blacklist', blacklistList = GM_getValue(blacklistKey) ? JSON.parse(GM_getValue(blacklistKey)) : [], blacklistFunction = { WebUrl: null, HtmlToList: null, ItemToNameJq: null, NameJqToNameText: null, DleButtonToItem: null, DleButtonStyle: null }, WebJqList = [{ WebUrl: "search.51job.com", HtmlToList: function () { return $('.el .t2 a[title]').closest('.el'); }, ItemToNameJq: function (item) { return $(item).find('.t2 a[title]'); }, NameJqToNameText: function (item) { return $(item).attr('title'); }, DleButtonToItem: function (item) { return $(item).closest('.el'); }, DleButtonStyle: 'margin: 0 10px;display: contents;' }, { WebUrl: "sou.zhaopin.com", HtmlToList: function () { return $('#listContent .clearfix .commpanyName a[title]').closest('.clearfix'); }, ItemToNameJq: function (item) { return $(item).find('.commpanyName a[title]'); }, NameJqToNameText: function (item) { return $(item).attr('title'); }, DleButtonToItem: function (item) { return $(item).closest('.clearfix'); }, DleButtonStyle: 'margin: 0 10px;display: inline-table;' }, { WebUrl: "www.zhipin.com", HtmlToList: function () { return $('.company-text h3 a[ka]').closest('li'); }, ItemToNameJq: function (item) { return $(item).find('.company-text h3 a[ka]'); }, NameJqToNameText: function (item) { return $(item).text(); }, DleButtonToItem: function (item) { return $(item).closest('li'); }, DleButtonStyle: 'margin: 0 10px;display: inline-table;' }, { WebUrl: "www.lagou.com", HtmlToList: function () { return $('li .company_name a[data-lg-tj-cid]').closest('li'); }, ItemToNameJq: function (item) { return $(item).find('.company_name a[data-lg-tj-cid]'); }, NameJqToNameText: function (item) { return $(item).text(); }, DleButtonToItem: function (item) { return $(item).closest('li'); }, DleButtonStyle: 'margin: 0 10px;display: inline-table;' }, { WebUrl: "www.liepin.com", HtmlToList: function () { return $('li .company-name a[title]').closest('li'); }, ItemToNameJq: function (item) { return $(item).find('.company-name a[title]'); }, NameJqToNameText: function (item) { return $(item).text(); }, DleButtonToItem: function (item) { return $(item).closest('li'); }, DleButtonStyle: 'margin: 0 10px;display: inline-flex;position: absolute;right: 12px;' }]; function blacklistInit() { for (let i = 0; i < WebJqList.length; i++) { if (WebJqList[i].WebUrl === window.location.host) { blacklistFunction = WebJqList[i]; break; } } blacklistFilter(); createDelDiv(); } function blacklistFilter() { blacklistFunction.HtmlToList().each(function (index, element) { let isShow = true; let name = blacklistFunction.NameJqToNameText(blacklistFunction.ItemToNameJq(element)); if (blacklistList.indexOf(name) > -1) { isShow = false; } else { for (let i = 0; i < blacklistList.length; i++) { if (new RegExp(blacklistList[i], 'i').test(name)) { isShow = false; break; } } } if (isShow) { $(element).show(); } else { $(element).hide(); } }); } function addDlacklistName(name) { name += ''; if (blacklistList.indexOf(name) === -1) { blacklistList.push(name); GM_setValue(blacklistKey, JSON.stringify(blacklistList)); } else { } blacklistFilter(); } function dleDlacklistName(name) { if (blacklistList.indexOf(name) > -1) { blacklistList.splice(blacklistList.indexOf(name), 1); GM_setValue(blacklistKey, JSON.stringify(blacklistList)); } blacklistFilter(); } function createDelDiv() { blacklistFunction.HtmlToList().each(function (index, element) { blacklistFunction.ItemToNameJq(element).after($('
').click(function () { addDlacklistName(blacklistFunction.NameJqToNameText(blacklistFunction.ItemToNameJq(blacklistFunction.DleButtonToItem(this)))); return false; })) }); } setTimeout(function () { blacklistInit(); }, 3000); })();