Indeed.com: Highlight non-sponsored jobs

This script just highlights sponsored and non-sponsored jobs by different colors for better visualization.

目前为 2016-06-15 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Indeed.com: Highlight non-sponsored jobs
  3. // @namespace localhost
  4. // @description This script just highlights sponsored and non-sponsored jobs by different colors for better visualization.
  5.  
  6. // @include *.indeed.com/*
  7. // @run-at document-end
  8.  
  9. // @author lukie80
  10. // @copyright Creative Commons Attribution-ShareAlike 3.0 Unported (CC-BY-SA 3.0)
  11. // @license http://creativecommons.org/licenses/by-sa/3.0/
  12. // @version 1.0
  13. // @lastupdated 2016.06.15
  14. //
  15. // ==/UserScript==
  16. //-------------------------------------------------------------------------------------------------------------------
  17.  
  18. //source: http://stackoverflow.com/a/9496574 - not needed for script, just here for educational purposes
  19. function getAllElementsWithAttribute(attribute)
  20. {
  21. var matchingElements = [];
  22. var allElements = document.getElementsByTagName('*');
  23. for (var i = 0, n = allElements.length; i < n; i++)
  24. {
  25. if (allElements[i].getAttribute(attribute) !== null)
  26. {
  27. // Element exists with attribute. Add to array.
  28. matchingElements.push(allElements[i]);
  29. }
  30. }
  31. return matchingElements;
  32. }
  33.  
  34. //source: http://stackoverflow.com/a/4275177 - needed
  35. function getElementsStartsWithId( id ) {
  36. var children = document.body.getElementsByTagName('*');
  37. var elements = [], child;
  38. for (var i = 0, length = children.length; i < length; i++) {
  39. child = children[i];
  40. if (child.id.substr(0, id.length) == id)
  41. elements.push(child);
  42. }
  43. return elements;
  44. }
  45.  
  46. var badDivs = getElementsStartsWithId("pj_");
  47. var goodDivs = getElementsStartsWithId("p_");
  48.  
  49. for (var i = 0; i < goodDivs.length; i++){
  50. goodDivs[i].style.background = '#F8F8F8';
  51. }
  52. for (var i = 0; i < badDivs.length; i++){
  53. badDivs[i].style.background = '#fff5ff';
  54. //badDivs[i].remove();
  55. //this can remove the sponsored jobs but this is not suggested
  56. //because they are not qualitative spam. However they are
  57. //quantitative spam.
  58. }
  59.  
  60. //-------------------------------------------------------------------------------------------------------------------