Skip to content

Instantly share code, notes, and snippets.

@jdc-cunningham
Created February 3, 2024 03:26
Show Gist options
  • Save jdc-cunningham/50b37caeac27900f5a4e1ff2c3c70b63 to your computer and use it in GitHub Desktop.
Save jdc-cunningham/50b37caeac27900f5a4e1ff2c3c70b63 to your computer and use it in GitHub Desktop.
Hacker News dev tools console job highlighter
document.querySelectorAll('.athing.comtr').forEach(job => {
const jobText = job.innerText.toLowerCase();
const rejectWords = ['europe', 'staff', 'sr.', 'senior', 'lead', 'principal', 'uk', 'spain', 'portugal', 'netherlands', 'berlin', 'germany', 'devops', 'eu', 'platform', 'onsite', 'hybrid'];
const wantWords = ['react', 'javascript', 'python', 'rails', 'node'];
const wanted = wantWords.some(word => jobText.includes(word));
if (wanted) {
const rejected = rejectWords.some(word => jobText.includes(word));
if (!rejected) {
job.style.backgroundColor = 'rgb(0, 255, 0, 0.3)';
} else {
job.remove();
}
} else {
job.remove();
}
});
@jdc-cunningham
Copy link
Author

Looks like this

rejected-text

@jdc-cunningham
Copy link
Author

Last one, bolder text, thick full width red bottom border


document.querySelectorAll('.athing.comtr').forEach(job => {
	const jobText = job.innerText.toLowerCase();

	const rejectWords = [
    'europe', 'staff', 'sr.', 'senior', 'lead', 'principal', 'uk', 'spain',
    'portugal', 'netherlands', 'berlin', 'germany', 'devops', 'eu', 'platform',
    'onsite', 'hybrid', 'java', '.NET', 'haskell', 'go', 'rust'
  ];

  const wantWords = ['react', 'javascript', 'python', 'rails', 'node'];
  
  const wanted = wantWords.some(word => jobText.includes(word));
  
  if (wanted) {
      const rejectFilter = rejectWords.filter(rejectWord => jobText.includes(rejectWord));
    
      if (!rejectFilter.length) {
        job.style.backgroundColor = 'rgb(0, 255, 0, 0.3)';
      } else {
        const jobComment = job.querySelector('.comment');
        jobComment.innerHTML = `<div style="display: block; border-bottom: 2px solid red;">` + rejectFilter.map(word => `<span style="color: red; font-weight: bold;">${word}</span>`).join(' ') + '</div>' + jobComment.innerHTML;
      }
  }
});

@jdc-cunningham
Copy link
Author

jdc-cunningham commented Feb 3, 2024

This does have false positives like "go" is probably the word more than the language

Also this highlights jobs that I almost match but don't meet eg. has JavaScript but it uses Rust

@jdc-cunningham
Copy link
Author

this one removes the comments without want words

document.querySelectorAll('.athing.comtr').forEach(job => {
	const jobText = job.innerText.toLowerCase();

	const rejectWords = [
    'europe', 'staff', 'sr.', 'senior', 'lead', 'principal', 'uk', 'spain',
    'portugal', 'netherlands', 'berlin', 'germany', 'devops', 'eu', 'platform',
    'onsite', 'hybrid', 'java', '.net', 'haskell', 'go', 'rust', 'c#', 'asp.net', 'sre'
  ];

  const wantWords = ['react', 'javascript', 'python', 'rails', 'node'];
  
  const wanted = wantWords.some(word => jobText.includes(word));
  
  if (wanted) {
      const rejectFilter = rejectWords.filter(rejectWord => jobText.includes(rejectWord));
    
      if (!rejectFilter.length) {
        job.style.backgroundColor = 'rgb(0, 255, 0, 0.3)';
      } else {
        const jobComment = job.querySelector('.comment');
        jobComment.innerHTML = `<div style="display: block; border-bottom: 2px solid red;">` + rejectFilter.map(word => `<span style="color: red; font-weight: bold;">${word}</span>`).join(' ') + '</div>' + jobComment.innerHTML;
      }
  } else { job.remove() }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment