1.购买服务器阿里云:服务器购买地址https://t.aliyun.com/U/E8o0aM若失效,可用地址
阿里云:
服务器购买地址
https://t.aliyun.com/U/E8o0aM若失效,可用地址
https://www.aliyun.com/daily-act/ecs/activity_selection?source=5176.29345612&userCode=49hts92d腾讯云:
https://curl.qcloud.com/wJpWmSfU若失效,可用地址
https://cloud.tencent.com/act/cps/redirect?redirect=2446&cps_key=ad201ee2ef3b771157f72ee5464b1fea&from=console华为云
https://activity.huaweicloud.com/cps.html?fromacct=64b5cf7cc11b4840bb4ed2ea0b2f4468&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=2019052.部署教程
3.代码如下
(() => {'use strict';// unit fragmentfunction Unit() {return `<div><label>单位</label><select class='swal2-select' data-time-type='1'>${Object.entries({1: '秒',60: '分',3600: '时'}).map((e) =>`<option value=${e[0]} ${GM_getValue('timeType') == e[0] ? 'selected' : ''}>${e[1]}</option>`).join('')}</select></div>`;}// time rangefunction AvailTime() {return ('<div><label>生效时段</label><input value="' +GM_getValue('availBegin', init.begin) +'" type="time" class="swal2-input" data-begin="1" style="width:28%"><input value="' +GM_getValue('availEnd', init.end) +'" type="time" class="swal2-input" data-end="1" style="width:30%"></div>');}// list fragmentfunction List() {return hosts.map((e) =>`<div><label>${e.name}</label><input class='swal2-input' value=${e.interval} type=number min=0 data-key=${e.key}></div>`).join('');}function setup() {let box;Swal.fire({title: '设置各站点刷新间隔',// icon: "question",html:Unit() +AvailTime() +`<div><label>统一调整</label><input class='swal2-input' type=number min=0 data-all-input=1></div>` +List(),showCloseButton: true,showCancelButton: true,focusConfirm: false,confirmButtonText: '确定',cancelButtonText: '取消',didOpen(el) {el = el.querySelector('#swal2-html-container');el.oninput = (e) => {if (e.target.value <= 0) {e.target.value = 0;}if (e.target.dataset.allInput == 1) {Array.from(el.querySelectorAll('input[data-key]')).forEach((inp) => {inp.value = e.target.value;});}};el.onchange = (e) => {if (e.target.type !== 'time') return;if (e.target.dataset.begin == 1 && e.target.nextElementSibling.value < e.target.value) {e.target.nextElementSibling.value = e.target.value;return;}if (e.target.dataset.end == 1 && e.target.previousElementSibling.value > e.target.value) {e.target.previousElementSibling.value = e.target.value;}};},willClose(el) {box = el;}}).then((res) => {if (res.isConfirmed) {GM_setValue('timeType', box.querySelector('.swal2-select').value);Array.from(box.querySelectorAll('input[data-key]')).forEach((e, i) => {GM_setValue(e.dataset.key, (hosts[i].interval = +e.value));});GM_setValue('availBegin', box.querySelector('input[data-begin]').value);GM_setValue('availEnd', box.querySelector('input[data-end]').value);run();}});}const init = {begin: '08:00',end: '22:00',timeType: 1};const hosts = [{host: 'www.zhaopin.com',key: 'zhilian',name: '智联',btn: '.login-after .refresh',interval: GM_getValue('zhilian', 15)},{host: 'www.51job.com',key: 'job51',name: '前程无忧',btn: '#refreshresume',interval: GM_getValue('job51', 15)},{host: 'c.liepin.com',key: 'liepin',name: '猎聘',btn: '#main-container .aside-vap-bottom-btn1',interval: GM_getValue('liepin', 15)}];let current = hosts.findIndex((e) => e.host === location.host);hosts.unshift(hosts.splice(current, 1)[0]);current = hosts[0];GM_registerMenuCommand('设置', setup /* { id: 1 } */);const isAvailable = () => {const now = new Date(),hm = (now.getHours() + '').padStart(2, 0) + ':' + (now.getMinutes() + '').padStart(2, 0);return hm > GM_getValue('availBegin', init.begin) && hm < GM_getValue('availEnd', init.end);};const run = () => {if (!isAvailable()) return;document.querySelector(current.btn)?.click();setTimeout(run, 1000 * current.interval * GM_getValue('timeType', init.timeType));};// sync data with other pageconst availChanged = (key, oldValue, newValue, remote) => {remote && run();};GM_addValueChangeListener('availBegin', availChanged);GM_addValueChangeListener('availEnd', availChanged);hosts.forEach((e) => {GM_addValueChangeListener(e.key, (key, oldValue, newValue, remote) => {if (!remote) return;e.interval = newValue;});});run();GM_addStyle('#swal2-html-container label{display:inline-block;width:4em;text-align:right;}' +'#swal2-html-container .swal2-select{border: 1px solid #d9d9d9;border-radius:0.1875em;}' +'#swal2-html-container .swal2-select,#swal2-html-container .swal2-input{width:60%;margin-right:0;margin-left:.5em;}');})();
解析
该脚本用于在设定的生效时段内,按自定义时间间隔自动点击三大招聘网站上的"刷新简历"按钮,提升简历曝光度。当前支持:
智联招聘(zhaopin.com)
前程无忧(51job.com)
猎聘(liepin.com)
支持在页面菜单里打开设置弹窗,统一或分别配置各站点刷新间隔、时间单位(秒/分/时)以及生效起止时间。多个页面之间通过 GM_* 存储与监听保持设置同步。
主要方法
Unit():生成"时间单位"下拉框的 HTML 片段(秒/分/时),默认取GM_getValue('timeType')。AvailTime():生成"生效时段(起/止)"的时间输入框片段,默认取availBegin/availEnd。List():按站点生成每个站的"刷新间隔"输入框列表(读取/回写各自的GM_getValue)。setup():打开 SweetAlert2 设置弹窗;处理"统一调整"输入同步各站点间隔;
约束起止时刻的有效性;
点击"确定"后将选择的单位、各站点间隔与生效时段写入
GM_setValue并调用run()。hosts:站点配置表包含域名、存储键、展示名、页面"刷新"按钮选择器、默认/已存的间隔。
根据当前
location.host将本页对应站点配置提前置顶,作为本页自动刷新目标。GM_registerMenuCommand('设置', setup):在油猴菜单注册"设置",打开配置弹窗。isAvailable():判断当前时间是否处于生效时段(availBegin < 当前HH:mm < availEnd)。run():核心执行器若处于生效时段,查找当前站点的"刷新简历"按钮并点击;
依据
当前站点间隔 × timeType递归setTimeout再次执行,实现循环刷新。GM_addValueChangeListener(...):跨页面同步监听
availBegin/availEnd变化:在"远程页面"更新时,本页重新run();监听各站点间隔键变化:远程更改时,更新本页对应
hosts[i].interval。GM_addStyle(...):为设置弹窗中的表单元素添加简单样式。
小提示
"刷新按钮"通过 CSS 选择器定位:
智联:
.login-after .refresh51job:
#refreshresume猎聘:
#main-container .aside-vap-bottom-btn1
如页面改版可能需要更新选择器。
注意:
本文部分变量已做脱敏处理,仅用于测试和学习研究,禁止用于商业用途,不能保证其合法性,准确性,完整性和有效性,请根据情况自行判断。技术层面需要提供帮助,可以通过打赏的方式进行探讨。
没有评论:
发表评论