Workday Jobs Tab Renamer

Rename tabs on myworkdayjobs.com based on job title and company name

  1. // ==UserScript==
  2. // @name Workday Jobs Tab Renamer
  3. // @namespace https://greasyfork.org/en/users/688917
  4. // @version 0.2
  5. // @description Rename tabs on myworkdayjobs.com based on job title and company name
  6. // @icon64 https://www.workday.com/favicon.ico
  7. // @match *://*.myworkdayjobs.com/*/job/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Function to extract the company name from the URL
  16. function getCompanyName(url) {
  17. const matches = url.match(/\/\/(.*?)\.myworkdayjobs/);
  18. if (matches) {
  19. // Assuming the company name is the first part of the subdomain
  20. const subdomainParts = matches[1].split('.');
  21. return subdomainParts.length > 0 ? subdomainParts[0] : null;
  22. }
  23. return null;
  24. }
  25.  
  26. // Function to rename the tab
  27. function renameTab() {
  28. const companyName = getCompanyName(window.location.href);
  29. const jobTitleElement = document.querySelector("#mainContent > div > div > div.css-e23il0 > div.css-cabox8 > div > h2");
  30. if (companyName && jobTitleElement) {
  31. const jobTitle = jobTitleElement.textContent.trim();
  32. document.title = `${jobTitle} - ${companyName}`;
  33. }
  34. }
  35.  
  36. // Wait for the page to load and the job title element to be available
  37. const observer = new MutationObserver((mutations, obs) => {
  38. const jobTitleElement = document.querySelector("#mainContent > div > div > div.css-e23il0 > div.css-cabox8 > div > h2");
  39. if (jobTitleElement) {
  40. renameTab();
  41. obs.disconnect(); // Stop observing once we've renamed the tab
  42. }
  43. });
  44.  
  45. observer.observe(document, {
  46. childList: true,
  47. subtree: true
  48. });
  49. })();