Last active
July 10, 2023 13:41
-
-
Save ngseke/fbab14ff51a6722948831c182f9737c6 to your computer and use it in GitHub Desktop.
LinkedIn X Glassdoor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name LinkedIn X Glassdoor | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Shortcut from LinkedIn to Glassdoor | |
// @author ngseke | |
// @match https://www.linkedin.com/jobs/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=linkedin.com | |
// @grant none | |
// ==/UserScript== | |
(function () { | |
const $ = (...args) => document.querySelector(...args) | |
const $$ = (...args) => document.querySelectorAll(...args) | |
const getLink = (keyword) => `https://www.glassdoor.com/Search/results.htm?keyword=${keyword}` | |
const renderDoorLink = (keyword) => { | |
const $link = document.createElement('a') | |
const attrs = { | |
href: getLink(keyword), | |
target: '_blank', | |
innerText: '🚪', | |
} | |
Object.assign($link, attrs) | |
$link.dataset.doorLink = '' | |
return $link | |
} | |
const handle = ($el) => { | |
if (!$el) return | |
const name = $el.innerText | |
const existedDoorLink = $el.parentNode.querySelector('[data-door-link]') | |
if (existedDoorLink) { | |
existedDoorLink.href = getLink(name) | |
return | |
} | |
const $doorLink = renderDoorLink(name) | |
$el.parentNode.append($doorLink) | |
} | |
const observeDom = () => { | |
const observer = new MutationObserver(() => { | |
const $companyName = $('.jobs-unified-top-card__primary-description a:first-child') | |
handle($companyName) | |
}) | |
observer.observe(document.body, { childList: true, subtree: true }) | |
} | |
observeDom() | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment