This userscript adds a button to edit pages on Stack Exchange sites that fixes most common grammatical and usage errors with a click and automatically composes an editing summary based on the changes made.
The rules included in the standard script are as follows:
- Uppercases lowercase "i"s in posts
- Corrects to proper spelling/capitalization of "Stack Overflow" and "Stack Exchange" in order to fit the legal naming requirements
- Expands "SO" and "SE" to "Stack Overflow" and "Stack Exchange," respectively
- Corrects to proper spelling/capitalization of...
- JavaScript
- JSFiddle
- jQuery
- HTML
- CSS
- JSON
- AJAX
- AngularJS
- PHP
- Android
- Oracle
- Windows
- SQL(ite)
- iOS
- C/C#/C++
- Java
- Ubuntu
- Linux
- WordPress
- Apache
- MySQL
- Git
- GitHub
- Capitalizes the first letter of new lines
- Removes common greetings
- Removes "thanks" and similar phrases
- Removes "Edit:" and similar modifiers
- Replaces the now-banned mysite.domain with example.domain
- Fixes improperly used contractions
- Corrects all-caps titles
The script can be easily expanded by adding rules to the edits
dictionary with the format given below:
anArbitraryName: {
expr: /aRegularExpressionForMatching/,
replacement: "What to replace it with (may include captured text like $1)",
reason: "an unpunctuated reason starting with a lowercase letter that will be formatted automatically and inserted into the edit summary"
},
If you fix any of my rules or come up with new ones, feel free to make a pull request.
If you notice any odd behavior of the script, please report an issue (this may seem obvious, but odd behavior might not seem like a "bug" in the traditional sense).
A test suite (with more than 600 tests) is available to test the most common replacements. The test suite runs the following tests for each of the configured replacements:
- Replacing the word in the middle of a sentence, e.g. "I use GITHUB to work."
- Replacing the word at the end of the sentence, e.g. "I use GITHUB."
- Applying the replacement in the body of the question.
- Applying the replacement in the title of the question.
- Avoid replacements for false positives, e.g. "I use GitHub to work."
To run the test suite locally, you need to install Node.js. Download the latest installer and run it to install Node.js and npm
. In your local clone of this project, run
npm install
to download and install the test dependencies. This only needs to be done once.
To run the test suite, run the following in the project's directory:
npm test
To add more tests, take a look at the test/test-edits.js
file.