refactor code about collect job info

This commit is contained in:
geekgeekrun
2026-02-06 05:43:53 +08:00
parent 9fc16106cd
commit eac79a9661
@@ -49,9 +49,8 @@ const attachRequestsListener = async (target: Target) => {
return return
} }
function handleJobDetailPage({ encryptJobId } = { encryptJobId: null }) { // FIXME: might not work
Promise.resolve() async function handleJobDetailPage({ encryptJobId } = { encryptJobId: null }) {
.then(async () => {
if (!encryptJobId) { if (!encryptJobId) {
return return
} }
@@ -60,7 +59,8 @@ const attachRequestsListener = async (target: Target) => {
({ encryptJobId }) => { ({ encryptJobId }) => {
return ( return (
location.href.startsWith(`https://www.zhipin.com/job_detail/${encryptJobId}`) && location.href.startsWith(`https://www.zhipin.com/job_detail/${encryptJobId}`) &&
document.readyState === 'complete' (!!document.querySelector('#main .job-banner') ||
!!document.documentElement.innerText?.includes(`您访问的页面不存在`))
) )
}, },
undefined, undefined,
@@ -105,8 +105,6 @@ const attachRequestsListener = async (target: Target) => {
} catch { } catch {
// //
} }
})
.catch(() => void 0)
} }
if (page.url().match(/^https:\/\/www.zhipin.com\/job_detail\/(.+)\.html/)) { if (page.url().match(/^https:\/\/www.zhipin.com\/job_detail\/(.+)\.html/)) {
@@ -200,7 +198,7 @@ const attachRequestsListener = async (target: Target) => {
) )
const requestBody = new URLSearchParams(response.request().postData()) const requestBody = new URLSearchParams(response.request().postData())
const securityIdInRequest = requestBody.get("securityId") const securityIdInRequest = requestBody.get('securityId')
const currentJobSecurityId = currentJobData?.securityId const currentJobSecurityId = currentJobData?.securityId
if (securityIdInRequest !== currentJobSecurityId) { if (securityIdInRequest !== currentJobSecurityId) {