resume_check

Boss|more...

目前為 2021-02-08 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         resume_check
// @namespace    http://tampermonkey.net/
// @version      0.9
// @description  Boss|more...
// @author       Lonely
// @match        https://www.zhipin.com/web/boss/*
// @match        https://www.baidu.com
// @require      https://cdn.jsdelivr.net/npm/vue/dist/vue.js
// @grant        GM_xmlhttpRequest
// ==/UserScript==

(function () {
    'use strict';

    (function () {
        // 做一个div套着,后续直接innerHTML一把嗦
        var div = document.createElement('div')
        div.id='script_ele_box'

        div.innerHTML = `
                        <div id="resume_app" @click='match' v-show='is_show()' style='height: 80px; width: 150px;
                         background-color: #43CD80; border-radius: 10px; top: 10%; left: 90%;
                          position: fixed;z-index: 999999'>
                            <p> <h3> {{ message }}</h3></p>
                            <p class='timer'>{{ update_area }}秒前更新</p>
                            <p class='preview'><a href='#' target='_blank'></a></p>
                        </div>
                        `
        document.body.appendChild(div);
    })()

    var app = new Vue({
        el: '#resume_app',
        data: {
            message: '点击匹配',
            update_area: 0,
            intervalId: null,
            start_time: ''
        },
        methods: {
            is_show: function () {
                return document.location.href === 'https://www.zhipin.com/web/boss/index'

            },
            // 定时器
            dateRefresh: function () {
                if (this.intervalId != null) return

                this.intervalId = setInterval(() => {
                    this.update_area += 1
                }, 1000);
            },
            // 停止定时器
            clear: function () {
                clearInterval(this.intervalId); //清除计时器
                this.intervalId = null; //设置为null
            },
            extract_experience: function () {
                // 提取经历部分的HTML代码
                if (document.location.href === 'https://www.zhipin.com/web/boss/index' && document.querySelector('.resume-detail')) {
                    return document.querySelector('.resume-detail').outerHTML
                }
                return null
            },
            match: function () {
                var experience_html = this.extract_experience()
                if (!experience_html) {
                    alert('请在简历页面点击匹配')
                    return
                }
                var self = this
                GM_xmlhttpRequest({
                    method: "POST",
                    url: "http://192.168.1.224:8888/api/v1/resume/parse_html_exp",
                    data: 'data=' + encodeURIComponent(experience_html),
                    headers: {
                        'accept': 'application/json',
                        'Content-Type': 'application/x-www-form-urlencoded',
                    },
                    onload: function (e) {
                        var python_response = JSON.parse(e.response)
                        var _a = document.querySelector('.preview > a')
                        self.update_area = 0
                        if (python_response.data.score > 80) {
                            self.message = `${python_response.data.name}:${python_response.data.score}分`
                            _a.href = python_response.data.file_path
                            _a.text = '预览'
                        } else {
                            _a.href = '#'
                            _a.text = ''
                            self.message = `${python_response.data.name}:${python_response.data.score}分`
                        }
                    }
                })
            }
        },
        created: function () {
            this.dateRefresh();
        },
        destroyed() {
            // 在页面销毁后,清除计时器
            this.clear();
        }
    })

})();