// ==UserScript== // @name Boss直聘活跃度显示 // @namespace http://tampermonkey.net/ // @version 0.7 // @description Boss直聘显示活跃时间,鼠标点击顶部导航栏栏即可显示出全部职位活跃度: // @author Winlam // @match https://www.zhipin.com/web/geek/job* // @icon https://www.google.com/s2/favicons?sz=64&domain=zhipin.com // @grant none // @license MIT // @downloadURL https://update.greasyfork.icu/scripts/514092/Boss%E7%9B%B4%E8%81%98%E6%B4%BB%E8%B7%83%E5%BA%A6%E6%98%BE%E7%A4%BA.user.js // @updateURL https://update.greasyfork.icu/scripts/514092/Boss%E7%9B%B4%E8%81%98%E6%B4%BB%E8%B7%83%E5%BA%A6%E6%98%BE%E7%A4%BA.meta.js // ==/UserScript== (function() { 'use strict'; let styles = document.createElement("style"); styles.textContent=` #wl_action_button{ width: 25px; height: 25px; background: #4c9696; border-radius: 50%; box-shadow: 1px 1px 2px 1px #ffffff;cursor: pointer;} #wl_tagsbar{ display: flex;align-items: end; position: absolute; color: #fff; top: 32%; margin-left: 15px; text-shadow: 1px 1px 7px #fdfdfd; } .w_active{ /*职位链接标签 是否已经设置过*/ padding-bottom: 10px !important; height:auto !important; } .acvt,.wl_juli{ /*默认*/ padding: 3px 8px; background: #f8f8f8; width: fit-content; border-radius: 8px; margin-top: 9px; font-size: 14px; } .wl_juli{padding:0;} .acvt-new{ /*日*/ background: #6dd0d0; } .acvt-online{ background: #e5f4e3; color: #40b14f; } `; document.head.appendChild(styles); let bossactive = {}; //encryptJobId:活跃字 let mlinkdata = new Map();//joblist api链接:对应的数据数组 let flag_doing = true; let headerbar,tags,currentLat,currentLon,action_button,showtags; // let headerbar = document.querySelector("#header"); // let tags = document.createElement("div"); // tags.id="wl_tagsbar"; // headerbar.prepend(tags); function toRadians(degrees) { return degrees * (Math.PI / 180); } function haversineDistance(lat1, lon1, lat2, lon2) { const R = 6371; const dLat = toRadians(lat2 - lat1); const dLon = toRadians(lon2 - lon1); const a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(toRadians(lat1)) * Math.cos(toRadians(lat2)) * Math.sin(dLon / 2) * Math.sin(dLon / 2); const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); const distance = R * c; //千米 return distance; } function getjuli(lat,log){ return new Promise(function(res,rej){ let distance = 0; if(currentLat==null||currentLon==null){ res(distance); } if (navigator.geolocation) { if(!currentLat && !currentLon){ navigator.geolocation.getCurrentPosition( (position) => { currentLat = position.coords.latitude; // 获取纬度 currentLon = position.coords.longitude; // 获取经度 // 你可以在这里调用计算距离的函数 distance = haversineDistance(currentLat, currentLon, lat, log); res(distance); }, (error) => { console.error('获取位置失败', error); }, { enableHighAccuracy: true, // 使能高精度定位 timeout: 5000, // 超时时间 maximumAge: 0 // 不使用缓存 } ); } //console.log(currentLat, currentLon, lat, log); distance = haversineDistance(currentLat, currentLon, lat, log); res(distance); } else { console.log("浏览器不支持地理位置服务。"); } res(distance); }) } function refresh_tags(text){ //if(!text){return;} if(!headerbar){ headerbar = document.querySelector("#header"); } if(!tags){ tags = document.createElement("div"); tags.id="wl_tagsbar"; action_button = document.createElement("div"); action_button.id="wl_action_button"; tags.prepend(action_button); showtags = document.createElement("div"); showtags.id="wl_showtags"; tags.append(showtags); headerbar.prepend(tags); } let wl_showtags = document.querySelector("#wl_showtags"); if(wl_showtags){ wl_showtags.innerHTML = text; } } //从网络中获得列表数组 function getlinks() { let data = window.performance .getEntries() .filter((item) => item.name.includes("/search/joblist.json?")).map((item) => item.name); return data[data.length - 1]; } //ul 工作列表 job-list-box function sortlist(ul){ refresh_tags("排序中...") // 给定的顺序 var order = ["在线","刚刚活跃","今日活跃","本周活跃", "3日内活跃","本月活跃","2月内活跃","3月内活跃","4月内活跃","5月内活跃","半年前活跃",""]; var orderMap = order.reduce((acc, item, index) => { acc[item] = index; return acc; }, {}); var liElements = Array.from(ul.children); // 对
  • 元素进行排序 liElements.sort((a, b) => { // 获取每个
  • 内的 .acvt 元素 let a_acvt = a.querySelector(".acvt"); let b_acvt = b.querySelector(".acvt"); // 获取文本内容,如果 .acvt 元素不存在则使用空字符串 let a_text = a_acvt ? a_acvt.innerText : ""; let b_text = b_acvt ? b_acvt.innerText : ""; return orderMap[a_text] - orderMap[b_text]; }); // 清空