Indeed.com hide certain employers

Provides an option on Indeed to select employers that you are uninterested in working for and collapse their openings in search results

  1. // ==UserScript==
  2. // @name Indeed.com hide certain employers
  3. // @namespace https://greatest.deepsurf.us/en/users/11592-max-starkenburg
  4. // @description Provides an option on Indeed to select employers that you are uninterested in working for and collapse their openings in search results
  5. // @include http*://*indeed.tld/*
  6. // @version 1
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. var employerName, employerRow, indicator, indicatorShow, indicatorEdit;
  11. var employers = document.querySelectorAll(".row [itemprop=name]");
  12. var hiddenEmployers = localStorage.hiddenEmployers ? localStorage.hiddenEmployers : "";
  13. for (var i=0; i<employers.length; i++) {
  14. var employer = employers[i];
  15. employerName = employers[i].textContent.trim();
  16. if (hiddenEmployers.indexOf(employerName) > -1) {
  17. employerRow = employer.closest(".row");
  18. employerRow.style.display = "none";
  19. indicator = document.createElement("div");
  20. indicator.textContent = "hidden employer";
  21. indicator.className = "row";
  22. indicator.style.position = "relative";
  23. indicator.style.color = "gray";
  24. indicatorShow = document.createElement("span");
  25. indicatorShow.textContent = " [show result] ";
  26. indicatorShow.style.cursor = "pointer";
  27. indicator.appendChild(indicatorShow);
  28. indicatorEdit = document.createElement("span");
  29. indicatorEdit.textContent = " [edit list] ";
  30. indicatorEdit.style.cursor = "pointer";
  31. indicator.appendChild(indicatorEdit);
  32. employerRow.parentNode.insertBefore(indicator,employerRow);
  33. indicatorShow.addEventListener("click",function() {
  34. if (this.textContent == " [show result] ") {
  35. this.parentNode.nextSibling.style.display = "block";
  36. this.textContent = " [hide result] ";
  37. } else {
  38. this.parentNode.nextSibling.style.display = "none";
  39. this.textContent = " [show result] ";
  40. }
  41. });
  42. indicatorEdit.addEventListener("click",function() {
  43. var existingList = document.getElementById("gm-hidden-employer-edit");
  44. if (existingList) {
  45. existingList.parentNode.removeChild(existingList);
  46. }
  47. var editList = document.createElement("div");
  48. editList.id = "gm-hidden-employer-edit";
  49. editList.innerHTML = '\
  50. <div style="position: absolute; top: calc(100% + 15px); padding: 15px; background-color: #fff; box-shadow: 1px 1px 5px #bbb; z-index: 2;"> \
  51. <div>One per line (text must match exactly)</div> \
  52. <textarea rows="5" cols="30">' + hiddenEmployers + '</textarea> \
  53. <div> \
  54. <input type="button" id="gm-hidden-employer-save" value="Save"/> \
  55. <input type="button" id="gm-hidden-employer-cancel" value="Cancel"/> \
  56. </div> \
  57. </div>';
  58. this.parentNode.appendChild(editList);
  59. document.getElementById("gm-hidden-employer-save").addEventListener("click", function() {
  60. localStorage.hiddenEmployers = editList.getElementsByTagName("textarea")[0].value;
  61. editList.parentNode.removeChild(editList);
  62. });
  63. document.getElementById("gm-hidden-employer-cancel").addEventListener("click", function() {
  64. editList.parentNode.removeChild(editList);
  65. });
  66. });
  67. }
  68. }
  69.  
  70. var mores = document.getElementsByClassName("more-link");
  71. for (var j=0; j<mores.length; j++) {
  72. var more = mores[j];
  73. var hideLink = document.createElement("span");
  74. hideLink.className = "sl";
  75. hideLink.textContent = "hide results from this employer";
  76. more.parentNode.insertBefore(hideLink, more);
  77. var hyphen = document.createTextNode(" - ");
  78. more.parentNode.insertBefore(hyphen, more);
  79. hideLink.addEventListener("click", function() {
  80. if (confirm('Hide results from this employer? You can undo this later.')) {
  81. employerName = this.closest(".row").querySelector("[itemprop=name]").textContent.trim();
  82. console.log(employerName);
  83. var employersRegexp = new RegExp("(^|\\n)" + employerName + "(\\n|$)", "g");
  84. if (!employersRegexp.test(localStorage.hiddenEmployers)) {
  85. localStorage.hiddenEmployers += "\n" + employerName;
  86. }
  87. this.closest(".row").style.display = "none";
  88. }
  89. });
  90. }