// ==UserScript== // @name 高级求职助手/招聘网站助手,支持前程无忧、智联招聘、BOSS直聘、拉钩、猎聘 // @namespace https://github.com/qq943260285 // @version 1.3 // @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== 'use strict'; (function () { 'use strict'; var toolSize = 50; var positionLeft = true; var isExpand = true; var body = $('body'); body.before(''); body.before(''); var isMobile = false, mousedownPosition = {x: 0, y: 0}, toolPosition = {x: 0, y: 0}; var 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; var left = X + mouseX - mousedownPosition.x; var 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'); var tool = $('\n
\n
\n \n
\n
').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"}); var menuItems = [{ ico: "fa-eye-slash", title: "黑名单管理", callback: function callback() { var div = $('\n
\n '); $.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 callback() { window.open("https://qq943260285.github.io"); } }, { ico: "fa-github", title: "github开源", callback: function callback() { window.open('https://github.com/qq943260285/tampermonkey-recruitment-tool.git'); } }]; var menu = $('\n
\n
\n ').css({"width": menuItems.length * 50 + 20 + "px"}); var createMenu = function createMenu() { menu.empty(); var _loop = function _loop(i) { menu.append($('
').click(function () { menuItems[i].callback(); })); }; for (var i = 0; i < menuItems.length; i++) { _loop(i); } }; createMenu(); tool.append(menu); toolRegion.append(tool); body.append(toolRegion); var win = $('\n
\n
\n
\n \n
\n
\n
\u6807\u9898
\n
\n
\n \u5185\u5BB9\n
\n
\n
\n ').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); var blacklistKey = 'blacklist', blacklistList = GM_getValue(blacklistKey) ? JSON.parse(GM_getValue(blacklistKey)) : [], blacklistFunction = { WebUrl: null, IsRefresh: null, DleButtonStyle: null, HtmlToList: function HtmlToList() { }, ItemToNameJq: function ItemToNameJq() { }, NameJqToNameText: function NameJqToNameText() { }, DleButtonToItem: function DleButtonToItem() { } }, WebJqList = [{ WebUrl: "search.51job.com", IsRefresh: false, DleButtonStyle: 'margin: 0 10px;display: contents;', HtmlToList: function HtmlToList() { return $('.el .t2 a[title]').closest('.el'); }, ItemToNameJq: function ItemToNameJq(item) { return $(item).find('.t2 a[title]'); }, NameJqToNameText: function NameJqToNameText(item) { return $(item).attr('title'); }, DleButtonToItem: function DleButtonToItem(item) { return $(item).closest('.el'); } }, { WebUrl: "sou.zhaopin.com", IsRefresh: true, DleButtonStyle: 'margin: 0 10px;display: inline-table;', HtmlToList: function HtmlToList() { return $('#listContent .clearfix .commpanyName a[title]').closest('.clearfix'); }, ItemToNameJq: function ItemToNameJq(item) { return $(item).find('.commpanyName a[title]'); }, NameJqToNameText: function NameJqToNameText(item) { return $(item).attr('title'); }, DleButtonToItem: function DleButtonToItem(item) { return $(item).closest('.clearfix'); } }, { WebUrl: "www.zhipin.com", IsRefresh: false, DleButtonStyle: 'margin: 0 10px;display: inline-table;', HtmlToList: function HtmlToList() { return $('.company-text h3 a[ka]').closest('li'); }, ItemToNameJq: function ItemToNameJq(item) { return $(item).find('.company-text h3 a[ka]'); }, NameJqToNameText: function NameJqToNameText(item) { return $(item).text(); }, DleButtonToItem: function DleButtonToItem(item) { return $(item).closest('li'); } }, { WebUrl: "www.lagou.com", IsRefresh: false, DleButtonStyle: 'margin: 0 10px;display: inline-table;', HtmlToList: function HtmlToList() { return $('li .company_name a[data-lg-tj-cid]').closest('li'); }, ItemToNameJq: function ItemToNameJq(item) { return $(item).find('.company_name a[data-lg-tj-cid]'); }, NameJqToNameText: function NameJqToNameText(item) { return $(item).text(); }, DleButtonToItem: function DleButtonToItem(item) { return $(item).closest('li'); } }, { WebUrl: "www.liepin.com", IsRefresh: false, DleButtonStyle: 'margin: 0 10px;display: inline-flex;position: absolute;right: 12px;', HtmlToList: function HtmlToList() { return $('li .company-name a[title]').closest('li'); }, ItemToNameJq: function ItemToNameJq(item) { return $(item).find('.company-name a[title]'); }, NameJqToNameText: function NameJqToNameText(item) { return $(item).text(); }, DleButtonToItem: function DleButtonToItem(item) { return $(item).closest('li'); } }]; function blacklistInit() { for (var i = 0; i < WebJqList.length; i++) { if (WebJqList[i].WebUrl === window.location.host) { blacklistFunction = WebJqList[i]; break; } } blacklistRefresh(); if (blacklistFunction.IsRefresh) setInterval(blacklistRefresh, 3000); } function blacklistRefresh() { blacklistFilter(); createDelDiv(); } function blacklistFilter() { blacklistFunction.HtmlToList().each(function (index, element) { var isShow = true; var name = blacklistFunction.NameJqToNameText(blacklistFunction.ItemToNameJq(element)); if (blacklistList.indexOf(name) > -1) { isShow = false; } else { for (var 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) { if ($(element).find('.xyzs-del-div').length === 0) { blacklistFunction.ItemToNameJq(element).after($('
').click(function () { addDlacklistName(blacklistFunction.NameJqToNameText(blacklistFunction.ItemToNameJq(blacklistFunction.DleButtonToItem(this)))); return false; })); } }); } blacklistInit(); })();