Indeed.com: Highlight non-sponsored jobs

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

当前为 2016-07-01 提交的版本,查看 最新版本

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