User:Daniel Quinlan/Scripts/Blame
| Description | Search revision history in pages and abuse filters to find changes. |
|---|---|
| Author | Daniel Quinlan |
| Status | Beta |
| Updated | 7 October 2025 |
| Browsers | Firefox, Safari, Chrome |
| Source | Blame.js |
Blame is a revision history search tool for pages and abuse filters. It quickly finds when text was added or removed, features multiple search methods and flexible options, and displays results in a detailed table.
Features
[edit]- Page and abuse filter support: Works on both pages and abuse filters.
- Multiple search methods: Supports binary (fast), linear (chronological), and complete (exhaustive) search.
- Flexible matching: Search with text or regular expressions, multiple revision filtering options, and other parameters.
- Fast and efficient: Revisions are cached to speed up additional searches. On pages, revisions are fetched in smart batches to improve performance and reduce server queries.
- Detailed results: Search results display match status alongside links to revision numbers, timestamps, and diffs.
- Global support: Works globally across Wikimedia sites.
- User-friendly interface: OOUI-based dialog with intuitive controls and help text.
Usage
[edit]- A Blame link appears in the Tools menu on eligible pages and abuse filters.
- Click the link to open the Blame dialog and configure your search:
- Search: Enter the text or regex pattern to find. If any text is selected when opening the dialog, the selection is automatically used as the initial search text.
- Matching: Choose between String (text substring) and Regex (regular expression) matching.
- String mode supports Case insensitive matching to ignore capitalization in searches.
- Regex mode supports the flags i (ignore case), m (multiline), and s (dotall).
- Search method: Binary search is the fastest method for most cases, Linear search scans revisions chronologically (slower, but simpler and guarantees the most recent change matching the search will be found), and Complete search checks every revision (comprehensive, but slow).
- Change type: Specify whether to find an Addition or a Removal. (Complete searches only check whether each revision matches the search rather than looking for a specific addition or removal.)
- Revisions: Optionally restrict searches by maximum count, skipping recent revisions, or by specifying start and end revisions using revision numbers or dates. The maximum revisions is automatically set to 500 for non-binary searches, but the value can be modified or cleared. If currently viewed revision is not the newest revision, it is automatically used as the initial start revision.
- If an option is automatically set, the field is highlighted in green. The highlight disappears if the option is modified or a search is started.
- Press the Enter key in text inputs or click Search to start your search.
- Press the Escape key or click ☒ to exit the dialog.
- Results appear at the bottom of the dialog. Red messages indicate errors, yellow messages are informational notices, and green messages indicate success.
Regular expressions
[edit]A regular expression (regex) is a sequence of characters that define a pattern to search for in text. For an interactive introduction on how to write regular expressions, visit RegexOne.
Blame supports these regex flags in the search dialog:
- i: Ignore case
- m: Multiline mode (
^and$match line breaks) - s: Dotall mode (
.matches newlines)
The u (Unicode) flag is always enabled.
Binary search
[edit]Binary search works best when the text was added or removed only once within the revision range. If text was added and removed multiple times, Linear search or Complete search may yield better results.
Binary search is usually the fastest method, typically finding results in 8 to 12 revision checks. Sometimes, extra revisions must be examined if the newest and oldest fetched versions have the same result. Linear search and Complete search are much slower in most cases, but can sometimes slightly outperform binary search when most revisions must be examined due to identical results.
Revisions
[edit]Revision filters are applied in order: first the start and end revision numbers or dates (if specified), then the maximum number of revisions to search, and finally any skip count.
Date input supports YYYY-MM-DDTHH:MM:SS (ISO 8601 format without a timezone) or YYYY-MM-DD formats. If the time is omitted, the full day is included. The timezone is always the timezone offset set in your user preferences at Preferences → Appearance under Time offset.
Installation
[edit]To install the Blame script, follow these steps:
- In your preferences, go to Preferences → Gadgets. At the bottom of the "Advanced" section, click the "Install scripts without having to manually edit JavaScript files (documentation)" checkbox, then click the "Save" button.
- Return to this page and click the blue "Install" button.
Alternatively, you can manually install it by adding the following code to your common.js file:
{{subst:iusc|User:Daniel Quinlan/Scripts/Blame.js}}
Configuration
[edit]There are no configuration settings. Advanced users can customize the appearance of the results section with CSS.
Notes
[edit]- Searching abuse filters is slower than pages because filter revisions must be extracted from HTML pages.
- Revisions that have been revision deleted or suppressed are skipped during searches unless the user has permission to view them.
- Identical page revisions are only fetched once (based on SHA-1 hashes).
- When switching between string and regex matching, previously selected options are preserved.