you are viewing a single comment's thread
view the rest of the comments
[–] 20 points 4 days ago* (1 child)

Ask and you shall receive

// ==UserScript==
// @name         Airport!
// @namespace    Airporty
// @version      2026-09-24
// @description  (Airport!)
// @match        https://*/*
// @grant        none
// ==/UserScript==

(() => {
    'use strict';
    const search = /plane/gi;
    const replaceWith = 'plane (Airport!)';
    const excludedTagNames = ['SCRIPT', 'STYLE', 'INPUT', 'TEXTAREA'];

    // walk through document's nodes collecting elements with text inside
    // (but filter out tags that should probably be skipped)
    const walker = document.createTreeWalker(
        document.body,
        NodeFilter.SHOW_TEXT,
        {
            acceptNode: node =>
            excludedTagNames.includes(node.parentElement?.tagName)
            ? NodeFilter.FILTER_REJECT
            : NodeFilter.FILTER_ACCEPT
        }
    );

    // loop through the planes, making (Airport!)s :)
    for (let node = walker.nextNode(); node; node = walker.nextNode()) {
        node.nodeValue = node.nodeValue.replace(search, replaceWith);
    }
})();
  • source
  • parent
  • hideshow 1 child comment