Skip to content

Instantly share code, notes, and snippets.

@i-bayanov
Last active March 3, 2024 19:33
Show Gist options
  • Save i-bayanov/ff72c09d1cb8ae6e8d8cc8ebae661c89 to your computer and use it in GitHub Desktop.
Save i-bayanov/ff72c09d1cb8ae6e8d8cc8ebae661c89 to your computer and use it in GitHub Desktop.
Сначала установить расширение Tampermonkey https://www.tampermonkey.net/, потом нажать на кнопку "Raw".
// ==UserScript==
// @name Raise the resume on Head Hunter
// @version 1.1.5
// @author Ilia Bayanov https://vk.com/ilia_bayanov
// @description Automatic resume promotion in the search hh.ru
// @description:ru Автоматическое продвижение резюме в поиске hh.ru
// @updateURL https://gist.github.com/i-bayanov/ff72c09d1cb8ae6e8d8cc8ebae661c89/raw/a2e54f11f39c62034577491d6721ae7f87d007a8/raise-the-resume.user.js
// @downloadURL https://gist.github.com/i-bayanov/ff72c09d1cb8ae6e8d8cc8ebae661c89/raw/a2e54f11f39c62034577491d6721ae7f87d007a8/raise-the-resume.user.js
// @include /^https:\/\/([^(hh)]+\.)?hh\.ru\/applicant\/resumes.*$/
// @icon https://i.hh.ru/favicons/70x70.png
// @run-at document-body
// @grant none
// ==/UserScript==
(() => {
'use strict';
const getDateOfNextUpdate = () => {
const dateArr = [].find.call(
document.getElementsByClassName('applicant-resumes-action'),
(el) => el.innerText.includes('Поднять вручную'),
)?.innerText.split(String.fromCodePoint(160));
if (!dateArr) return;
const day = Number(dateArr[1]) || dateArr[1];
if (day === 'сегодня') {
const t = new Date();
return new Date(
t.getFullYear(),
t.getMonth(),
t.getDate(),
Number(dateArr[3].split(':')[0]),
Number(dateArr[3].split(':')[1]) + 1,
);
}
const months = [
'января', 'февраля', 'марта', 'апреля', 'мая', 'июня',
'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря',
];
const month = months.indexOf(dateArr[2]);
const year = Number(dateArr[3]);
const hours = Number(dateArr[5].split(':')[0]);
const minutes = Number(dateArr[5].split(':')[1]);
return new Date(year, month, day, hours, minutes + 1);
};
const handleMutation = () => {
const raiseButton = [].find.call(
document.getElementsByClassName('bloko-link'),
(el) => el.innerText === 'Поднять в поиске',
);
if (raiseButton) raiseButton.click();
const dateOfNextUpdate = getDateOfNextUpdate();
if (!dateOfNextUpdate) return;
const reloadDelay = dateOfNextUpdate - Date.now();
const hours = Math.floor(reloadDelay / 1000 / 60 / 60);
const hoursWords = ['часов', 'час', 'часа', 'часа'];
const minutes = Math.floor((reloadDelay - 1000 * 60 * 60 * hours) / 1000 / 60);
console.log(`Обновление страницы через ${hours} ${hoursWords[hours]} и ${minutes} минут`);
setTimeout(() => window.location.reload(), reloadDelay);
observer.disconnect();
};
const observer = new MutationObserver(handleMutation);
observer.observe(document, {
childList: true,
subtree: true,
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment