LinkedIn Company Matcher Revised

Check if LinkedIn job company is in IND km sponsor list

  1. // ==UserScript==
  2. // @name LinkedIn Company Matcher Revised
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3
  5. // @description Check if LinkedIn job company is in IND km sponsor list
  6. // @author JP Zhang
  7. // @match https://www.linkedin.com/jobs/*
  8. // @grant GM_xmlhttpRequest
  9. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js
  10. // @license MPL-2.0
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // Fetch the IND km sponsor list (supposed to be a JSON file)
  17. GM_xmlhttpRequest({
  18. method: "GET",
  19. url: "https://raw.githubusercontent.com/zjplab/Dutch_KM_Sponsored_Company_Lists/main/km_company.json",
  20. onload: function(response) {
  21. let indCompanies = JSON.parse(response.responseText);
  22.  
  23. // Run the check every 5 seconds
  24. setInterval(function() {
  25. // Find the company name in the page
  26. let companyNameElement = document.querySelector(".job-details-jobs-unified-top-card__primary-description-container a.app-aware-link");
  27. if (!companyNameElement) {
  28. console.log("Company name element not found");
  29. return;
  30. }
  31. let companyName = companyNameElement.textContent.trim().toLowerCase();
  32.  
  33. // Find the location in the page
  34. let locationAndTimeElement = companyNameElement.parentElement.textContent;
  35. let locationAndTime = locationAndTimeElement.split("·")[1];
  36. let location = locationAndTime ? locationAndTime.split("·")[0].trim() : ''; // Extracting only the location part
  37.  
  38. // Print the company name and location
  39. console.log("Company name: " + companyName);
  40. console.log("Location: " + location);
  41.  
  42. if (location.includes('Netherlands') || location.includes('荷兰') || location.includes('尼德兰') || location.includes('Amsterdam Area')) {
  43. let companyLink = companyNameElement; // Save the object for the company name link
  44.  
  45. console.time("Matching time"); // Start timer
  46.  
  47. let matched = indCompanies.sponsors.some(function(sponsor) {
  48. if (isKMismatchSubstring(companyName, sponsor.toLowerCase(), 3)) {
  49. // The company name is a K-mismatch substring of this company,
  50. // so you can change the CSS as needed.
  51. companyLink.style.fontWeight = 'bold';
  52. companyLink.style.color = 'green';
  53. return true;
  54. }
  55. return false;
  56. });
  57.  
  58. console.timeEnd("Matching time"); // End timer and log time
  59.  
  60. if (!matched) {
  61. // The company name did not match any sponsor,
  62. // so you can change the CSS as needed.
  63. console.log("Not matched!");
  64. companyLink.style.fontWeight = 'bold';
  65. companyLink.style.color = 'red';
  66. }
  67. }
  68. }, 5000);
  69. }
  70. });
  71. })();
  72.  
  73. function isKMismatchSubstring(query, text, k) {
  74. let m = query.length;
  75. for (let i = 0; i <= text.length - m; i++) {
  76. let mismatches = 0;
  77. for (let j = 0; j < m; j++) {
  78. if (text[i + j] !== query[j]) {
  79. mismatches++;
  80. if (mismatches > k) {
  81. break;
  82. }
  83. }
  84. }
  85. if (mismatches <= k) {
  86. return true;
  87. }
  88. }
  89. return false;
  90. }