LinkedIn search results

Colour LinkedIn job search results that have already been seen

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         LinkedIn search results
// @namespace    http://sam.haslers.info/
// @version      2024-06-07
// @license      MIT
// @description  Colour LinkedIn job search results that have already been seen
// @author       Sam Hasler
// @match        https://www.linkedin.com/jobs/collections/*
// @match        https://www.linkedin.com/jobs/collections/similar-jobs/*
// @match        https://www.linkedin.com/jobs/search/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=linkedin.com
// @grant        GM_addStyle
// ==/UserScript==


(function() {
  'use strict';
  const OBSERVER_OPTIONS = {
    childList:true,
    subtree: true,
    attributes: true, // 2024-03-06 added to pick up youtube element reuse
    characterData: true, // 2024-03-06 added to pick up youtube element reuse
  };
  const debouncedObserver = (updateDomFn, debounceMs = 10_000) => {
    let isUpdating = false, updateSceduled;

    const observer = new MutationObserver(function(mutationArray, observer) {
      mutationArray.forEach(mutation => {
        // @TODO configure what triggers re-run
        if (!updateSceduled){ // && mutation.addedNodes){
          isUpdating = true;
          //console.log("%cupdateSceduled", `background-color:magenta;`);
          updateSceduled = setTimeout(() => {
            //console.log("%cupdating", `background-color:magenta;`);
            updateDomFn();
            updateSceduled = void 0;
            isUpdating = false;
            //console.log("%cupdate done", `background-color:magenta;`);
          }, debounceMs);
          //  } else if (isUpdating){
          //the setTimeout will run updateDomFn AFTER other DOMNodeInserted events, so this shouldn't happen:
          //    console.warn("DOM Modified during update", e.target);
        }
      });
    });
    observer.observe(document.firstElementChild, OBSERVER_OPTIONS);
    return observer;
  }

  GM_addStyle(`
.job-card-container:has([data-state="viewed" ])                                             { background-color: beige;     }
.job-card-container:has([data-state="viewed" ]).jobs-search-results-list__list-item--active { background-color: yellow;    }
.job-card-container:has([data-state="saved"  ])                                             { background-color: lightblue; }
.job-card-container:has([data-state="saved"  ]).jobs-search-results-list__list-item--active { background-color: blue;      }
.job-card-container:has([data-state="applied"])                                             { background-color: lightgreen;}
.job-card-container:has([data-state="applied"]).jobs-search-results-list__list-item--active { background-color: green;     }
`)
  const colorResults = () => {
    document
      .querySelectorAll('.job-card-container__footer-job-state')
      .forEach(s => s.setAttribute('data-state', s.innerText.toLowerCase()));
  }

  colorResults();
  debouncedObserver(colorResults,250);
})();