Back to Repository

hh

0 upvotes
By cmyser.fast.i@gmail.com
Manual (context menu)

Match Pattern

https://*.hh.ru/*

Script Code

;(() => {
	'use strict'
	const e = 'coverLetter_1',
		t = 1500,
		n = {
			naviItems: '.supernova-navi-item.supernova-navi-item_lvl-2',
			blacklist: '[data-qa=vacancy__blacklist-show-add]',
			addBlacklist: '[data-qa=vacancy__blacklist-menu-add-vacancy]',
			pagerNext: '[data-qa="pager-next"]',
			modalOverlay: '[data-qa="modal-overlay"]',
			alertBox: '[data-qa="magritte-alert"]',
			countryConfirmBtn: '[data-qa="relocation-warning-confirm"]',
			chatikCloseBtn: '[data-qa="chatik-close-chatik"]',
			vacancyCards: '[data-qa="vacancy-serp__vacancy"]',
			vacancyCard: '[data-qa="vacancy-response-link-top"]',
			vacancyTitle: "[data-qa='serp-item__title']",
			addCoverLetter: '[data-qa="vacancy-response-letter-toggle-text"]',
			coverLetterInput: '#cover-letter textarea',
			respondBtn: '[data-qa="vacancy-serp__vacancy_response"]',
			sendBtn: '[data-qa="vacancy-response-letter-submit"]',
			vacancyTitlePopup: '[data-qa="title-description"]',
			resumeDropdown: '[data-qa="resume-title"]',
			addCoverLetterPopup: '[data-qa="add-cover-letter"]',
			coverLetterInputPopup: '[data-qa="vacancy-response-popup-form-letter-input"]',
			respondBtnPopup: '[data-qa="vacancy-response-submit-popup"]',
		},
		a = e => new Promise(t => setTimeout(t, e))
	let c = !1
	function o() {
		return c
	}
	function r(e) {
		c = e
	}
	const i = 'hh.ru/vacancy',
		l = ['hh.ru/vacancies', 'hh.ru/search/vacancy'],
		s = {
			coverLetter_1:
				`Добрый день! 

У меня большой опыт в веб разработке

За время работы я преуспел в создании больших и масштабируемых систем.

Я знаком с большим технологическим стэком, что позволяет мне создавать надежные системы и принимать верные решения.

Я могу подойти на эту вакансию и думаю что мы точно сработаемся.

Спасибо за рассмотрение моего отклика. Готов ответить на все ваши вопросы.

С уважением,
Кирилл Новгородцев`,
		}
	function u(e, t) {
		const a = document.querySelector(n.coverLetterInput) || document.querySelector(n.coverLetterInputPopup)
		a &&
			(function (e, t = '') {
				if (
					[window.HTMLInputElement, window.HTMLSelectElement, window.HTMLTextAreaElement].includes(
						e?.__proto__?.constructor,
					)
				) {
					Object.getOwnPropertyDescriptor(e.__proto__, 'value').set.call(e, t)
					const n = new Event('input', { bubbles: !0 })
					e.dispatchEvent(n)
				}
			})(a, s[e].replace('{#vacancyName}', t))
	}
	async function d() {
		document.querySelector(n.countryConfirmBtn)?.click()
	}
	async function y() {
		const e = document.querySelector(n.alertBox),
			c = e?.nextElementSibling?.querySelectorAll('button')
		;(c?.[1]?.click(), await a(t))
	}
	async function p(c) {
		;(document.querySelector(n.addCoverLetter).click(), await a(t))
		const o = document.querySelector(n.sendBtn)
		;(u(e, c), o.click(), await a(t), document.querySelector(n.chatikCloseBtn)?.click())
	}
	async function v(c) {
		const o = document.querySelector(n.respondBtnPopup)
		;(await (async function () {
			const e = document.querySelector(n.vacancyTitlePopup),
				c = document.querySelector(n.resumeDropdown),
				o = document.querySelector(n.addCoverLetterPopup)
			;(c.click(), await a(t))
			const r = document.querySelector('[data-qa="magritte-select-option-403451acff0f2d944f0039ed1f34585a555344"]')
			;(r?.click(), o?.click() || e.click())
		})(),
			await a(t),
			u(e, c),
			o.click(),
			await a(t))
	}
	async function m() {
		const e = document.querySelector('[data-action="submit-responses"]')
		if (o())
			return (r(!1), (e.textContent = 'Отправить отклики'), void console.log('⏹️ Отправка откликов остановлена'))
		;(r(!0), (e.textContent = 'Остановить отправку'), console.log('▶️ Начата отправка откликов'))
		try {
			await (async function () {
				const e = window.location.href,
					c = i,
					r = l
				e.includes(c)
					? await (async function () {
							const e = document.querySelector(n.singleVacancy)
							e && (e.click(), await p())
						})()
					: r.some(t => e.includes(t)) &&
						(await (async function () {
							const e = document.querySelectorAll(n.vacancyCards)
							if (e.length)
								for (const c of e) {
									if (!o()) break
									;(c.scrollIntoView({ behavior: 'smooth', block: 'center' }),
										(c.style.boxShadow = '0 0 8px #0059b3'))
									const e = c.querySelector(n.vacancyTitle)?.innerText,
										r = c.querySelector(n.respondBtn)
									;(['Respond', 'Откликнуться'].includes(r?.innerText) &&
										(r.click(),
										await a(t),
										await d(),
										await y(),
										document.querySelector(n.modalOverlay) ? await v(e) : await p(e)),
										(c.style.boxShadow = ''))
								}
						})())
			})()
		} catch (e) {
			console.error('Ошибка при отправке откликов:', e)
		} finally {
			;(r(!1), (e.textContent = 'Отправить отклики'), console.log('✅ Отправка откликов завершена'))
		}
	}
	function q(e, t = 'div', n = 'Помощь') {
		return Array.from(e.querySelectorAll(t)).find(e => e.textContent.trim() === n && 0 === e.children.length)
	}
	!(async function () {
		;(await (async function () {
			await a(t)
			const e = document.querySelectorAll(n.naviItems),
				c = e[4].cloneNode(!0),
				o = q(c)
			;(o.setAttribute('data-action', 'submit-responses'),
				(o.textContent = 'Отправить отклики'),
				e[4].insertAdjacentElement('afterend', c),
				c.querySelector('[data-action="submit-responses"]').addEventListener('click', m))
		})(),
			await (async function () {
				const e = document.querySelectorAll(n.naviItems),
					t = e[4].cloneNode(!0)
				;((q(t).textContent = 'Поддержать проект'),
					t.removeAttribute('href'),
					(t.style.cursor = 'pointer'),
					t.addEventListener('click', () => {
						window.open('https://boosty.to/ia-stepanov/donate', '_blank')
					}),
					e[5].insertAdjacentElement('afterend', t))
			})())
	})()
})()
Install requires the InjectJS Chrome extension. Scripts run only on sites matching the pattern above. Review code before installing any community script.