Greasy Fork

高级求职助手/招聘网站助手,支持前程无忧、智联招聘、BOSS直聘、拉钩、猎聘

1.快捷添加企业黑名单;2.支持正则表达式黑名单;3.支持前程无忧、智联招聘、BOSS直聘、拉钩、猎聘;4.各大网站黑名单数据连通。

当前为 2019-03-24 提交的版本,查看 最新版本

// ==UserScript==
// @name         高级求职助手/招聘网站助手,支持前程无忧、智联招聘、BOSS直聘、拉钩、猎聘
// @namespace    https://github.com/qq943260285
// @version      1.3
// @description  1.快捷添加企业黑名单;2.支持正则表达式黑名单;3.支持前程无忧、智联招聘、BOSS直聘、拉钩、猎聘;4.各大网站黑名单数据连通。
// @author       小宇专属([email protected])
// @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
// ==/UserScript==
'use strict';
(function () {
    'use strict';
    var toolSize = 50;
    var positionLeft = true;
    var isExpand = true;
    var body = $('body');
    body.before('<link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />');
    body.before('<style>\n            .xyzs-tool-region{\n            position: fixed;\n             z-index: 20480;\n             left: 0;\n             top: 0;\n             width: 100%;\n             height: 100%;\n            }\n            .xyzs-tool{\n             background-color: #ff5c4c;\n             width: ' + toolSize + 'px;\n             height: ' + toolSize + 'px;\n             border-radius:' + toolSize / 2 + 'px;\n             -moz-border-radius:' + toolSize / 2 + 'px; \n             position: absolute;\n             left: 10px;\n             bottom: 10px;\n             cursor: move;\n             pointer-events:auto;\n             -moz-box-shadow:1px 1px 10px rgba(82, 82, 82, 0.74);;\n             -webkit-box-shadow:1px 1px 10px rgba(82, 82, 82, 0.74);\n             box-shadow:1px 1px 10px rgba(82, 82, 82, 0.74);\n            }\n            .xyzs-tool .menu{\n            width: 200px;\n            height: 50px;\n            position: absolute;\n            left: ' + toolSize + 'px;\n            display: none;\n            transition: display 3s;\n            padding: 0 10px;\n            }\n            .xyzs-tool .fa-tool{\n             font-size: 27px;\n             color: #FFF!important;\n            }\n            .xyzs-menu-item{\n            height: 30px;\n            width: 30px;\n            border-radius:15px;\n            float: left;\n            margin: 10px;\n            background-color: #ff5c4c;\n             -moz-box-shadow:1px 1px 10px rgba(82, 82, 82, 0.74);;\n             -webkit-box-shadow:1px 1px 10px rgba(82, 82, 82, 0.74);\n             box-shadow:1px 1px 10px rgba(82, 82, 82, 0.74);\n             text-align: center;\n            }\n            .xyzs-menu-item:hover{\n             -moz-box-shadow:1px 1px 15px rgb(35,35,35);\n             -webkit-box-shadow:1px 1px 15px rgb(35,35,35);\n             box-shadow:1px 1px 15px rgb(35,35,35);\n            }\n            .xyzs-menu-item .fa-item{\n                font-size: 20px;\n                margin: auto 0;\n                width: 30px;\n                height: 30px;\n                line-height: 30px;\n                cursor: pointer;\n                color: #fff;\n            }\n            .xyzs-menu-item .fa-item:hover{\n\n            }\n            /*===== win =====*/\n            .xyzs-win{\n                width: 500px;\n                margin: 0 auto;\n                position: relative;\n                outline: 0;\n                top: 100px;\n                pointer-events:auto;\n            }\n            .xyzs-modal-content{\n                border-radius: 5px;\n                background-clip: padding-box;\n                background-color: #fff;\n                -moz-box-shadow:1px 1px 10px rgba(82, 82, 82, 0.74);;\n                -webkit-box-shadow:1px 1px 10px rgba(82, 82, 82, 0.74);\n                box-shadow:1px 1px 10px rgba(82, 82, 82, 0.74);\n                pointer-events:auto;\n                border: solid 1px #ff5c4c;\n            }\n            .xyzs-modal-close{\n                z-index: 1;\n                position: absolute;\n                right: 12px;\n                top: 8px;\n                overflow: hidden;\n                cursor: pointer;\n            }\n            .xyzs-icon-ios-close{\n                font-size: 25px;\n                color: #999;\n            }\n            .xyzs-modal-header{\n                border-bottom: 1px solid #e8eaec;\n                padding: 10px 16px;\n                text-align: left;\n                font-size: 15px;\n                font-weight: bold;\n                font-family: cursive;\n            }\n            .xyzs-modal-body{\n                padding: 16px;\n                font-size: 12px;\n            }\n\n            .xyzs-enterprise-list{\n                width: 100%;\n                height: 300px;\n                overflow-y: auto;\n                overflow-x: hidden;\n            }\n            .xyzs-enterprise-item{\n                /*height: 20px;*/\n                line-height: 20px;\n                margin: 5px;\n                font-size: 12px;\n                padding: 5px 12px;\n                border: solid 1px #dedede;\n            }\n            .xyzs-enterprise-item-ico{\n                color: #ff5c4c;\n                float: right;\n                font-size: 18px;\n            }\n\n            .xyzs-scrollbar::-webkit-scrollbar-track {\n              -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);\n              background-color: #F5F5F5;\n              border-radius:5px\n            }\n\n            .xyzs-scrollbar::-webkit-scrollbar {\n              width: 10px;\n              background-color: #F5F5F5;\n            }\n\n            .xyzs-scrollbar::-webkit-scrollbar-thumb {\n              background-color: rgba(255,92,76,0.7);\n              border-radius:5px\n            }\n            .xyzs-scrollbar::-webkit-scrollbar-thumb:hover {\n              background-color: #ff5c4c;\n            }\n            /*=== \u529F\u80FD ===*/\n            .xyzs-del-div{\n                color: #ff5c4c;\n                font-size: 20px;\n                cursor: pointer;\n            }\n            .xyzs-del-ico{\n            \n                color: #ff5c4c!important;\n            }\n        </style>');
    var isMobile = false, mousedownPosition = {x: 0, y: 0}, toolPosition = {x: 0, y: 0};
    var toolRegion = $('<div class="xyzs-tool-region"></div>').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        <div class=\'xyzs-tool\'>\n        <div style="position: absolute;text-align: center;width: 50px;top: 10px;color: #fff;">\n        <i class="fa fa-wrench fa-tool" title="\u5DE5\u5177\u7BB1"></i>\n        </div>\n        </div>').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                    <div class="xyzs-enterprise-list xyzs-scrollbar" ></div>\n                ');
            $.each(blacklistList, function (index, item) {
                div.append($('<div class="xyzs-enterprise-item">' + item + '</div>').append($('<i class="fa fa-times xyzs-enterprise-item-ico" title="\u5220\u9664" item-name="' + item + '"></i>').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    <div id=\'xyzs-menu\' class=\'menu\'>\n    </div>\n    ').css({"width": menuItems.length * 50 + 20 + "px"});
    var createMenu = function createMenu() {
        menu.empty();
        var _loop = function _loop(i) {
            menu.append($('<div class="xyzs-menu-item"><i class="fa ' + menuItems[i].ico + ' fa-item " title="' + menuItems[i].title + '"></i></div>').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        <div class="xyzs-win">\n            <div class="xyzs-modal-content">\n                <div class="xyzs-modal-close">\n                    <i title="\u5173\u95ED" class="fa fa-remove xyzs-icon-ios-close"></i>\n                </div>\n                <div class="xyzs-modal-header">\n                    <div class="xyzs-modal-header-inner">\u6807\u9898</div>\n                </div>\n                <div class="xyzs-modal-body">\n                    \u5185\u5BB9\n                </div>\n            </div>\n        </div>\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($('<div title="加入黑名单" style="' + blacklistFunction.DleButtonStyle + '" class="xyzs-del-div"><i class="fa fa-trash xyzs-del-ico"></i></div>').click(function () {
                    addDlacklistName(blacklistFunction.NameJqToNameText(blacklistFunction.ItemToNameJq(blacklistFunction.DleButtonToItem(this))));
                    return false;
                }));
            }
        });
    }

    blacklistInit();
})();