# Bullshit.js

> A JavaScript library with the mission-critical purpose of translating marketing-speak into human-readable text.

**Showcase URL:** https://shipdocs.sh/showcase/78b36dc4-1990-4c30-b8f7-c06800904871
**Repository:** https://github.com/mourner/bullshit.js
**Docs count:** 4

## Overview

## Project Overview

### What this project actually is

Bullshit.js is a JavaScript bookmarklet that identifies and highlights specific "bullshit" terms within the text content of a web page.

### Tech stack

*   JavaScript
*   esbuild (for bundling)
*   eslint (for linting)
*   findandreplacedomtext (library for DOM manipulation)

### High-level architecture

The core logic resides in `src/replace.js`. This file imports a list of terms from `src/terms.js`. It then uses the `findandreplacedomtext` library to find occurrences of these terms within the `document.body`. When a term is found, the `revealBullshit` function is called to replace the original text with a modified version, wrapped in an `<abbr>` tag with a red style. The `package.json` defines build scripts using `esbuild` to bundle `src/replace.js` into the `bullshit.js` file, which is the output for the bookmarklet.

### Entry points

1.  **`src/replace.js`**: This is the main source file for the bookmarklet's logic. When the bookmarklet is executed, this script is loaded and run in the context of the current web page.
2.  **`bullshit.js`**: This is the bundled output file. It's the script that is directly included in the bookmarklet's `href` attribute (as seen in `index.html`). When the bookmarklet is clicked, this script is fetched and executed, triggering the DOM manipulation defined in `src/replace.js`.
3.  **`index.html`**: This file serves as a landing page that explains what Bullshit.js is and provides the bookmarklet link. It also includes a `debug.html` which directly includes the `bullshit.js` script for testing purposes.

### Key concepts

1.  **`src/terms.js`**: This file contains a large array of regular expressions that define the "bullshit" terms to be detected. Understanding the structure and content of this file is crucial for knowing what the script targets.
2.  **`src/replace.js`**:
    *   **`bullshitRe`**: This regular expression is constructed from `bullshitTerms` and is used to find the target words in the DOM.
    *   **`revealBullshit({text})`**: This function takes the matched text, applies some simple transformations (e.g., adding "ting" or "ted"), and returns an `<abbr>` element with a red style and the transformed text as its content. This is how the "bullshit" is visually identified on the page.
3.  **`findandreplacedomtext`**: This external library is the workhorse for modifying the DOM. The script uses its `findAndReplaceDOMText` function with the `document.body` as the target, the `bullshitRe` as the search pattern, and `revealBullshit` as the replacement function.
4.  **Bookmarklet Structure (`index.html`)**: The `index.html` file demonstrates how the `bullshit.js` script is intended to be used as a bookmarklet. The `javascript:(function(){...}())` structure shows how to dynamically create and append a script tag to the current page's DOM.

## All docs

- **Bullshit.js** (overview)
- **Example Usage** (module)
- **Bookmarklet Code** (module)
- **Build Script** (module)

Browse the interactive showcase: https://shipdocs.sh/showcase/78b36dc4-1990-4c30-b8f7-c06800904871
