Skip to content

Instantly share code, notes, and snippets.

@juliandescottes
Last active January 17, 2025 11:04
Show Gist options
  • Save juliandescottes/06a455fd255602b2e2de7711ed6737db to your computer and use it in GitHub Desktop.
Save juliandescottes/06a455fd255602b2e2de7711ed6737db to your computer and use it in GitHub Desktop.
Find all ids used in devtools CSS

get text from: https://searchfox.org/mozilla-central/search?q=%5C%23.*%28%5C%7B%7C%28%2C%5Cn%29%29&path=devtools%2F**%2F*.css&case=false&regexp=true

js: [...new Set([...str.matchAll(/\#([^ .:({\[]+).*(?:\{|(?:,\n))/g)].map(([_, id]) => id))].sort().join("\n")

then run following bash script

#!/bin/bash

# Usage: ./find_strings.sh "string1,string2,string3" /path/to/folder

# Check for proper usage
if [ "$#" -ne 2 ]; then
  echo "Usage: $0 \"string1,string2,string3\" /path/to/folder"
  exit 1
fi

# Input arguments
SEARCH_TERMS=$1
TARGET_FOLDER=$2

# Ensure the target folder exists
if [ ! -d "$TARGET_FOLDER" ]; then
  echo "Error: Folder '$TARGET_FOLDER' does not exist."
  exit 1
fi

# Split the comma-separated search terms into an array
IFS=',' read -r -a TERMS_ARRAY <<< "$SEARCH_TERMS"

# File extensions to search in
FILE_EXTENSIONS="*.js *.xhtml *.html"

# Loop through each search term and check for matches
echo "Searching for terms in .js, .xhtml, and .html files under $TARGET_FOLDER"
for TERM in "${TERMS_ARRAY[@]}"; do
  echo -n "Checking for '$TERM': "
  if grep -rE --include="*.js" --include="*.xhtml" --include="*.html" "$TERM" "$TARGET_FOLDER" > /dev/null 2>&1; then
    echo "Match found"
  else
    echo "No match found"
  fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment