- HTML 80%
- JavaScript 11%
- TypeScript 9%
- Python <1%
ATProtocol-Playground #
Scripts and tools for experimenting with ATProto and BSky.app.
Features #
- Element Evaluator Tool: A browser-side tool for identifying and evaluating DOM elements on AtProtocol-style websites
- BSky Cleaner Userscript: A Tampermonkey-compatible userscript to hide/remove/replace elements on bsky.app
Quick Start #
Element Evaluator Tool #
The element evaluator is a TypeScript module that scans web pages to identify elements like bookmarks, reposts, and display names, then generates rules to hide or remove them.
Using the Dev UI #
-
Build the project:
npm install npm run build -
Load the evaluator in your browser console (on any page):
// Import and initialize the dev UI const script = document.createElement('script'); script.src = 'path/to/dist/tools/element-evaluator/index.js'; script.type = 'module'; document.head.appendChild(script); // Then in console: initElementEvaluatorDevUI(); -
The dev UI overlay will appear in the top-right corner with:
- Scan Page: Click to scan the current page for candidates
- Preview: Click "Preview" on any candidate to highlight matching elements
- Actions: Mark candidates as hide/remove/replace rules
- Apply Rules: Apply all rules and enable MutationObserver for SPA updates
- Export Rules: Download rules as JSON for use in the userscript
Programmatic API #
import { scanDocument, generateRule, applyRules } from './tools/element-evaluator';
// Scan for elements
const candidates = await scanDocument({
roles: ['bookmark', 'repost', 'displayname'],
minConfidence: 0.5,
includeHidden: false
});
// Generate a rule
const rule = generateRule(candidates[0], 'remove');
// Apply rules
const controller = applyRules([rule], {
useMutationObserver: true,
debounceMs: 300,
debug: true
});
// Stop observing later
controller.stop();
BSky Cleaner Userscript #
A Tampermonkey userscript to automatically hide/remove elements on bsky.app.
Installation #
-
Install Tampermonkey:
- Chrome/Edge: Tampermonkey Extension
- Firefox: Tampermonkey Add-on
-
Install the Script:
- Open Tampermonkey dashboard (click extension icon → Dashboard)
- Click "Create a new script"
- Copy the entire contents of
userscripts/bsky-cleaner.user.jsinto the editor - Save (Ctrl+S / Cmd+S)
- The script is now active on bsky.app
-
Customize Settings: Edit the
SETTINGSblock at the top of the script:const SETTINGS = { enabled: true, mode: 'remove', // or 'hide' or 'replace' removeBookmark: true, removeRepost: true, hideDisplayName: false, customSelectors: [ // Add your custom rules here ], mutationObserver: true, debounceMs: 300, debug: false, dryRun: false };
Finding Custom Selectors #
- Open bsky.app in your browser
- Right-click the element you want to target → Inspect
- In DevTools, right-click the highlighted element → Copy → Copy selector
- Add it to
customSelectorsin the script:customSelectors: [ { selector: "#your-copied-selector", action: "remove" } ] - Save and reload bsky.app
Testing with Dry Run #
To test selectors without making changes:
- Set
dryRun: trueanddebug: truein SETTINGS - Open browser console (F12)
- Reload bsky.app
- Check console logs to see what would be modified
- Adjust selectors as needed
- Set
dryRun: falsewhen ready
Example Custom Rules #
customSelectors: [
// Remove specific buttons
{ selector: "button[aria-label='Share']", action: "remove" },
// Hide display names but keep structure
{ selector: ".display-name, [data-testid='displayName']", action: "hide" },
// Replace text content
{ selector: ".handle", action: "replace", replaceText: "[user]" }
]
Development #
Project Structure #
.
├── tools/
│ └── element-evaluator/ # Element evaluator module
│ ├── types.ts # TypeScript type definitions
│ ├── evaluator.ts # Core scanning and rule logic
│ ├── dev-ui.ts # Browser dev UI overlay
│ └── index.ts # Main export
├── userscripts/
│ └── bsky-cleaner.user.js # Tampermonkey userscript
├── tests/
│ └── integration/ # Puppeteer integration tests
│ ├── evaluator.test.js
│ ├── userscript.test.js
│ └── test-fixtures.html
└── package.json
Building #
npm install
npm run build
The compiled JavaScript will be in dist/.
Running Tests #
# Run all tests
npm test
# Run integration tests only
npm run test:integration
Code Quality #
# Lint code
npm run lint
# Format code
npm run format
How It Works #
Element Evaluator #
The evaluator uses heuristics to identify elements:
-
Bookmark Detection:
- Matches aria-label, title, or class containing "bookmark", "save"
- Checks for button elements with bookmark-related testids
-
Repost Detection:
- Matches aria-label, title, or class containing "repost", "reshare", "boost"
- Identifies share/quote buttons
-
Display Name Detection:
- Matches classes like "displayName", "profile-name"
- Checks data-testid attributes
- Validates text patterns (not handles, reasonable length)
-
Selector Generation:
- Uses unique IDs when available
- Falls back to class + tag combinations
- Adds nth-child selectors for specificity
BSky Cleaner Userscript #
The userscript:
- Runs on page load (document-idle)
- Applies rules to matching elements using
querySelectorAll - Watches for changes with MutationObserver (for SPA navigation)
- Debounces updates to avoid performance issues
- Supports multiple modes: hide (CSS), remove (DOM), replace (text)
Security & Privacy #
- Browser-only execution: All code runs in your browser
- No external requests: The userscript doesn't send data anywhere
- No credentials required: Tools work on public pages
- Open source: Review the code before installing
Important: Do not embed API keys, tokens, or secrets in any scripts. The tools are designed to work with publicly accessible DOM elements only.
Troubleshooting #
Userscript not working #
- Check Tampermonkey is enabled: Click extension icon, verify script shows "Enabled"
- Verify match pattern: Script only runs on
*://bsky.app/*by default - Check browser console: Set
debug: trueand look for error messages - Reload the page: Some SPA changes require a full reload
Selectors not matching #
- Verify selector in DevTools: Use
document.querySelector("your-selector")in console - Check element visibility: Hidden elements won't match unless
includeHidden: true - Inspect dynamic content: Some elements load after page init; MutationObserver should catch them
- Use more specific selectors: Combine multiple attributes for reliability
Performance issues #
- Reduce debounce interval: Set
debounceMsto a smaller value (but not too small) - Disable MutationObserver: Set
mutationObserver: falseif page is static - Limit custom selectors: Too many selectors can slow down page
- Use 'hide' instead of 'remove': Removing elements triggers more DOM recalculation
Contributing #
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Run
npm run lintandnpm run format - Submit a pull request
License #
MIT - See LICENSE file