Created
September 10, 2026 19:52
-
-
Save xeoncross/6cecf003add7e074be178c6ec8bcdb93 to your computer and use it in GitHub Desktop.
Automatically clicks the "…more" link on LinkedIn job descriptions so the full text is always shown
This file contains hidden or 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 Job Description Auto-Expander | |
| // @namespace https://tampermonkey.net/ | |
| // @version 1.0.0 | |
| // @description Automatically clicks the "…more" link on LinkedIn job descriptions so the full text is always shown | |
| // @author xeoncross | |
| // @match https://www.linkedin.com/jobs/* | |
| // @run-at document-idle | |
| // @grant none | |
| // ==/UserScript== | |
| (function () { | |
| 'use strict'; | |
| // The numeric suffix (job posting id) changes per listing, but the prefix | |
| // is stable — this scopes us to the "About the job" panel specifically, | |
| // not the "About the company" or feed-post "more" buttons that reuse the | |
| // same button markup elsewhere on the page. | |
| const JOB_DESC_CONTAINER_SELECTOR = '[id^="JobDetails_AboutTheJob_"]'; | |
| // This data-testid is the one reliable hook on the button itself — | |
| // everything else about it (class names) is auto-generated and changes | |
| // between page loads / listings. | |
| const EXPAND_BUTTON_SELECTOR = 'button[data-testid="expandable-text-button"]'; | |
| // Track buttons we've already clicked so a mutation triggered by our own | |
| // click (or an unrelated re-render) doesn't cause repeat clicks. | |
| const clickedButtons = new WeakSet(); | |
| function expandWithin(root) { | |
| if (!root || typeof root.querySelectorAll !== 'function') return; | |
| const containers = []; | |
| // The root passed in might itself be the job-description container... | |
| if (root.matches && root.matches(JOB_DESC_CONTAINER_SELECTOR)) { | |
| containers.push(root); | |
| } | |
| // ...or it might just contain one (or several, across re-renders). | |
| root.querySelectorAll(JOB_DESC_CONTAINER_SELECTOR).forEach((el) => containers.push(el)); | |
| containers.forEach((container) => { | |
| const btn = container.querySelector(EXPAND_BUTTON_SELECTOR); | |
| if (!btn || clickedButtons.has(btn)) return; | |
| clickedButtons.add(btn); | |
| btn.click(); | |
| }); | |
| } | |
| // Handle the case where the panel is already on the page when this script | |
| // first runs (e.g. script re-injected, or Tampermonkey ran a beat late). | |
| expandWithin(document); | |
| // LinkedIn's job search page is a single-page app: clicking a different | |
| // job card swaps the "About the job" panel's contents in place without a | |
| // full navigation, so we need to watch for DOM changes rather than relying | |
| // on page-load events. | |
| let debounceHandle = null; | |
| const observer = new MutationObserver((mutations) => { | |
| // Debounce: a single job-card click can trigger a burst of dozens of | |
| // mutations as LinkedIn re-renders; we only need to scan once after | |
| // things settle. | |
| clearTimeout(debounceHandle); | |
| debounceHandle = setTimeout(() => { | |
| for (const mutation of mutations) { | |
| mutation.addedNodes.forEach((node) => { | |
| if (node.nodeType === Node.ELEMENT_NODE) { | |
| expandWithin(node); | |
| } | |
| }); | |
| } | |
| }, 150); | |
| }); | |
| observer.observe(document.body, { | |
| childList: true, | |
| subtree: true, | |
| }); | |
| // Belt-and-suspenders fallback: in case some render path doesn't trigger | |
| // a childList mutation the observer catches (e.g. attribute-only swaps), | |
| // periodically re-check. querySelector is cheap, so this is negligible. | |
| setInterval(() => expandWithin(document), 1000); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment