FANDOM


You may be looking for the similar AutoEditPages or FindAndReplace.

MassEdit is a script that enables users to create a set of inputted pages or edit/delete/find-and-replace content from a set of individual pages, categories, or namespaces. It can affix templates to the top or bottom of articles, add categories to pages, remove or replace all instances of a word or phrase, or create new articles. Users can adjust the rate of edit at will through the addition of a window object.

Due to the potential for abuse in the form of vandalism or spam, the script can only be used by high-level local staff (i.e. admins, content-moderators, and bots).

Installation

See also: Help:Including additional CSS and JS, Help:Advanced CSS and JS
  • For personal use, add the code snippet below to your global.js page (for use on all wikis) or your common.js page on your wiki (for use on a single wiki). Note that personal JS must be enabled for your account.
importArticles({
    type: 'script',
    articles: [
        'u:dev:MassEdit/code.js',
    ]
});
importArticles — Best Practices for installing JavaScript on FANDOM
The importArticles statement is designed to combine multiple HTTP requests into a single data transfer, allowing multiple scripts to load and execute faster. If you've been installing several different scripts, your JavaScript file has probably accumulated unnecessary import statements. Click "Expand" to learn how to efficiently batch import scripts to speed up performance and make your code look cleaner. One other approach is by using the MediaWiki:ImportJS.
If your JavaScript file has several lines of code that say importScript, importScriptPage, or importArticles, you may be able to combine them! By batch importing a collection of scripts with a single import, your JavaScript code will load faster and look cleaner. Consider the example below. On the left is an example of what your JavaScript file might currently look like. On the right is how you could improve that code.
Multiple imports — messy and slow One import — clean and efficient
importScriptPage('AjaxRC/code.js','dev');
 
importScript('MediaWiki:localScript.js');
 
importArticle({
  type: 'script',
  article: 'u:dev:FloatingToc/code.js'
});
 
importScriptPage('page1.js', 'wikiname');
 
importScriptPage('page2.js', 'wikiname');
importArticles({
    type: 'script',
    articles: [
        'u:dev:AjaxRC/code.js',
        'MediaWiki:localScript.js',
        'u:dev:FloatingToc/code.js',
        'u:wikiname:page1.js',
        'u:wikiname:page2.js'
    ]
});
Note: In this example, pay close attention to the placement of commas and other punctuation. For people who aren't familiar with programming (and even those who are!), a common mistake when writing code is to accidentally delete, forget, or misplace critical symbols like commas or quotation marks. This can cause a syntax error that breaks the code. Carefully follow the convention shown here when using importArticles.
But there's much more to importArticles than just this! For more examples and advanced usage, see the help page at Help:Including additional JavaScript and CSS.

Configuration

Users may further configure the script through the addition of a window object denoting their preferences. Users may adjust the edit rate of the script by modifying the integer value of editInterval. An example config object is shown below.

window.massEditConfig = {
    editInterval: 1500
};
Variables Type Default value(s)
editInterval Integer 1000

General usage

In addition to the standard usage of the "prepend" and "append" options to edit content of existing pages, these options may be used interchangeably to create a set of new pages based on the inputted values of the pages text area. Selecting either option and inputting page titles of nonexistent pages creates these pages automatically, allowing for a quick and efficient means of publishing new articles from a template or text extract.

Furthermore, though the find-and-replace function may be used as intended to locate and replace wikitext, HTML, or plaintext from existing articles, it may also be used to remove content from pages. Leaving the "New Content" field blank is counted as an empty string, allowing for the removal of the content of the "Target Content" field from the articles in question.

It is important to note that the script does not account for case sensitivity in the find-and-replace function. Upper and lowercase variations of the same word or phrase are treated separately and will require multiple iterations to replace as needed. In future, it is possible that a case sensitivity option will be added as per FindAndReplace's precedent.

Users are also provided with the ability to edit/delete/replace content from pages in a set of inputted categories. Selecting the "Categories" dropdown option and including the names of the categories in the textarea edits all extant pages currently in the category. (Note: Category titles may be included as Category:Example Category or simply as Example Category.)

In addition to the above category-based editing, users may also edit pages belonging to certain legitimate namespaces, separating individual namespace numbers (0 for main namespace, 4 for Project namespace, etc.) by line breaks, as per standard usage instructions.

In either case, a total of 500 page members (5000 for bots) will be edited per namespace or category, as per standard API limits for allpages and categorymembers queries.

Changelog

05-02-17
Initial revision
06-02-17
Revision of regex, removal of character limit
18-12-17
Retrofitting of I18n-js, addition of "find-and-delete" option, addition of config options, cleanup
07-01-18
Addition of find-and-replace function for set of pages; improved/expanded error handling for nonexistent pages, empty input fields, and pages without target text; general cleanup
12-04-18
Addition of category-based editing/find-and-replace function
17-04-18
Addition of namespace-based editing/find-and-replace function
24-05-18
Removal of static config-based edit summary in favor of modal-based summary textbox; assorted cosmetic and improper input behavior fixes