// ==UserScript== // @name boss直聘自动沟通助手 // @namespace npm/vite-plugin-monkey // @version 0.0.1 // @author monkey // @icon https://vitejs.dev/logo.svg // @match https://www.zhipin.com/* // @require http://code.jquery.com/jquery-2.1.1.min.js // @require https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/core-js/3.21.1/minified.min.js // @require https://cdn.jsdelivr.net/npm/react@18.2.0/umd/react.production.min.js // @require https://cdn.jsdelivr.net/npm/react-dom@18.2.0/umd/react-dom.production.min.js // @grant GM_xmlhttpRequest // @grant window.close // @description boss直聘辅助沟通助手 // @downloadURL none // ==/UserScript== (e=>{const o=document.createElement("style");o.dataset.source="vite-plugin-monkey",o.innerText=e,document.head.appendChild(o)})(` .boss-container{--background-color: orange;--font-color: #fff;position:fixed;left:50px;bottom:150px;display:flex;flex-direction:column;align-items:center;gap:10px;z-index:999}.boss-conversation-container .button{color:var(--font-color);background:var(--background-color);border:none;border-radius:5px;padding:6px 5px}.boss-conversation-setting{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);width:400px;height:400px;background:#eef;z-index:9999}.boss-conversation-container .multiple-publish{padding:5px;border-radius:5px} `); var W=Object.defineProperty;var U=(r,c,s)=>c in r?W(r,c,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[c]=s;var u=(r,c,s)=>(U(r,typeof c!="symbol"?c+"":c,s),s);(function(r,c){"use strict";var s={},R={get exports(){return s},set exports(e){s=e}},g={};/** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var _=r,k=Symbol.for("react.element"),C=Symbol.for("react.fragment"),I=Object.prototype.hasOwnProperty,L=_.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,P={key:!0,ref:!0,__self:!0,__source:!0};function x(e,t,n){var i,o={},l=null,a=null;n!==void 0&&(l=""+n),t.key!==void 0&&(l=""+t.key),t.ref!==void 0&&(a=t.ref);for(i in t)I.call(t,i)&&!P.hasOwnProperty(i)&&(o[i]=t[i]);if(e&&e.defaultProps)for(i in t=e.defaultProps,t)o[i]===void 0&&(o[i]=t[i]);return{$$typeof:k,type:e,key:l,ref:a,props:o,_owner:L.current}}g.Fragment=C,g.jsx=x,g.jsxs=x,function(e){e.exports=g}(R);var f={},b=c;f.createRoot=b.createRoot,f.hydrateRoot=b.hydrateRoot;const h=e=>e==null,d=e=>{const t=e.reduce((n,i,o)=>(n+=i,o.btn-startchat");return!h(t)||/job_detail/.test(location.pathname)}static isList(){return d(["geek/recommend","geek/job"]).test(location.pathname)}}const v="conversation_config",T={concurrentLimit:2,maxLimit:30,executeInterval:1e4,targetList:["[Rr]eact"],excludeList:["985","211","硕士"],automation:!1,idleMap:{}};class m{constructor(){u(this,"config",{});this.syncReadData()}syncReadData(){const t=localStorage.getItem(v);if(h(t)){this.config=T;return}try{this.config=JSON.parse(t)}catch(n){console.error(n)}}syncWriteData(){localStorage.setItem(v,JSON.stringify(this.config))}}class E{constructor(t,n){u(this,"timer");this.polling=t,this.ms=n}togglePolling(){this.polling=!this.polling}startPolling(){this.polling=!0}stopPolling(){this.polling=!1}get status(){return this.polling}clear(){const t=window.clearInterval;t(this.timer)}start(t){const n=window.setInterval;n(()=>{t()},this.ms)}}class y{constructor(){u(this,"polling",{});u(this,"setting",{});this.init()}init(){this.setting=new m,this.polling=new E(this.setting.config.automation,this.setting.config.executeInterval),this.polling.status&&this.start()}executeIdleQueue(){if(this.setting.config.maxLimit<=0){this.polling.clear();return}if(Object.values(this.setting.config.idleMap).filter(t=>!t.status).length===0){this.polling.status&&this.navigateNextPage(),this.polling.clear();return}for(let t=0;t!i[1].status).pop();n&&(this.setting.config.idleMap[n[0]].status=!0,n&&window.open(n[0]))}this.setting.syncWriteData()}start(){this.polling.start(()=>{this.setting.syncReadData(),this.addJobTask(),this.executeIdleQueue()})}addJobTask(){document.querySelectorAll(".job-list-box>li a.job-card-left").forEach(n=>{h(this.setting.config.idleMap[n.href])&&(this.setting.config.idleMap[n.href]={status:!1})})}navigateNextPage(){var a;let t="";const n=/(page)=([0-9])+/,i=location.search.length!==0,o=parseInt(((a=n.exec(location.search))==null?void 0:a[2])||"1")+1;/page=[0-9]+/.test(location.search)?t=location.search.replace(n,`$1=${o}`):t=location.search+`${i?"&":"?"}page=${o}`;const l=`${location.origin}${location.pathname}${t}`;window.location.href=l}}function N(){const e=()=>{new y().start()};return s.jsx("button",{className:"button",onClick:e,children:"一键投递"})}function D(){var n;const e=r.useRef();r.useEffect(()=>{e.current=new y},[]);const t=()=>{e.current&&(e.current.polling.togglePolling(),e.current.setting.config.automation=e.current.polling.status,e.current.setting.syncWriteData(),e.current.polling.status&&e.current.start())};return s.jsx("button",{className:"button",onClick:t,children:(n=e.current)!=null&&n.polling.status?"关闭自动轮询":"开启自动轮询"})}const O=(e=!1)=>{const[t,n]=r.useState(e);return[t,{setFalse(){n(!1)},setTrue(){n(!0)},toggle(){n(!t)},set(o){n(o)}}]};function j(e){const{type:t}=e,[n,i]=r.useState(),o=a=>{const w=new m,S=a.currentTarget.value.split(",");t==="target"?w.config.targetList=S:t==="exclude"&&(w.config.excludeList=S)},l=a=>{i(a.target.value)};return s.jsxs(s.Fragment,{children:[s.jsxs("h5",{children:[t,":"]}),s.jsx("textarea",{onInput:l,value:n}),s.jsx("button",{onClick:o,children:"保存"})]})}function M(){return s.jsxs("div",{className:"boss-conversation-setting",children:["设置",s.jsx(j,{type:"target"}),s.jsx(j,{type:"exclude"})]})}function B(){const[e,{toggle:t}]=O();return s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"button",onClick:()=>{t()},children:"设置"}),e&&c.createPortal(s.jsx(M,{}),document.body)]})}function F(){return p.isList()?s.jsxs("div",{className:"boss-container boss-conversation-container",children:[s.jsx(N,{}),s.jsx(D,{}),s.jsx(B,{})]}):s.jsx(s.Fragment,{})}function A(){return s.jsx(F,{})}const q="";f.createRoot((()=>{const e=document.createElement("div");return document.body.append(e),e})()).render(s.jsx(r.StrictMode,{children:s.jsx(A,{})}));class J{constructor(){u(this,"mountedTimer");u(this,"setting",new m);this.start()}checkCondition(){const t=document.querySelector(".job-sec-text");if(h(t))return!1;const n=d(this.setting.config.targetList).test(t.textContent),i=d(this.setting.config.excludeList).test(t.textContent);return n&&!i}publish(){if(this.setting.config.maxLimit<=0)return;const t=document.querySelector(".btn-container>.btn-startchat");t?(t.click(),this.setting.config.automation&&this.setting.config.maxLimit--,this.setting.syncWriteData()):(console.log("没有找到沟通按钮"),window.close())}start(){this.mountedTimer=window.setInterval(()=>{if(!this.checkCondition()){window.close(),clearInterval(this.mountedTimer);return}const t=document.querySelector(".btn-container>.btn-startchat"),n=document.querySelector(".left-title"),i=document.querySelector(".dialog-container");if(!p.isDetail()){clearInterval(this.mountedTimer),window.close();return}this.publish(),(i||n||t.textContent==="继续沟通")&&(clearInterval(this.mountedTimer),window.close())},3e3)}}p.isDetail()&&new J().start()})(React,ReactDOM);