Fandom

Wikia Developers Wiki

Linksweeper

846pages on
this wiki
Add New Page
Talk1 Share

Linksweeper removes backlinks (links, templates, files, and categories) from pages listed in special pages such as Special:Wantedpages, Special:Whatlinkshere, and Special:Wantedfiles. It also allows clean-up of links entered in the dialog box.

Important Note: Be careful when cleaning up categories. Due to the way links are created this script will also remove categories from pages, and not just their links (needs a fix at some point), e.g. [[Category:Sweepy]] and [[:Category:Sweepy]].

Installation

Add this JavaScript on your wiki:

Personal
Special:Mypage/common.js
linkSweepConfirmation = true;
LinkSweeperDelay = 1000;
importArticles({ type: 'script', articles: [
    'u:dev:Linksweeper/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.


Features

  • Removes templates, file links (including from gallery), and normal links
  • Pulls in links to remove from special pages or category
  • Shows backlinks in the modal (popup) from any page
  • Toolbar link
  • Button to fetch all redlinks in a page

Instructions

Click "remove backlinks" button on Special:WantedPages or Special:Whatlinkshere. One can also change some script settings by putting the options before the importarticles:

window.linkSweepConfirmation = true; 
window.linkSweeperDelay = 1000; //milliseconds
window.linkSweeperRedlist = {"wantedpages" : 1};
window.categoryList = [];

LinkSweepConfirmation adds a confirm dialog before attempting to remove the links, set true to show this dialog always. LinkSweeperDelay is the number of milliseconds before the next removal, this prevents flooding the wiki with too many requests.

The category allows users to add custom categories to fetch links to clean, e.g. :

window.categoryList = ["myfavcat", "spam"]

The linkSweeperRedlist consists of pages where the link sweeper will show up the to help remove links. It can be configured to work in additional special pages by adding the canonical name of a special page. However, it has only been tested with the default special pages (the ones below), and may not work in others. To use this configuration add each name as in the example below (canonical name in quotes, followed by colon and "1" , followed by a comma):

window.linkSweeperRedlist = {
      "wantedpages": 1,
      "whatlinkshere": 1,
      "wantedfiles": 1,
      "listredirects": 1,
      "uncategorizedpages": 1
}

Completely removing a link

By default the scripts only removes the square brackets from the link. However, there is a checkbox "delete links?" that enables a more aggressive mode, and completely removes the link from a page:

  • Normal mode - Replaces a link like [[Bazooka]] with "Bazooka"
  • Delete mode - Replaces a link like [[Bazooka]] with "" (empty text)

Notes

  • It will only check a max of 500 backlinks.
  • It will not work on links constructed by templates or lua modules.
  • It will automatically append "--<nowiki>" to the module namespace to eliminate those invalid reports.

History

  • 2016/05/05 Added button to fetch all redlinks in a page and improved template detection
  • 2016/04/16 Added custom list of categories to fetch pages
  • 2016/04/01: Added support for cleaning templates, added category button, button for batch removal in special pages
  • 2016/03/17: Added support for cleaning links in galleries
  • 2016/03/16: Added support for removing many links at once, added show backlinks button
  • 2016/03/12: Added Link to Wikia oasis skin (mytools) and "?action=delete"
  • 2016/03/10: Bug fix (normalize page titles: compare spaces, colon trick
  • 2016/03/09: Bug fixes and new features (arbitrary link page, custom summary, support for Special:Wantedfiles, namespace, delete & de-link)
  • 2016/03/05: Initial commit

See also

Start a Discussion Discussions about Linksweeper

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.