User:Alex 21/script-references

User:Alex 21/script-references.js is a script that moves all references declared within the article into the declaration of Reflist at the end of the article, to tidy up the article's contents just the readable prose and declared reference names. Any unnamed references are included with this move and are provided with a newly-generated reference name.

Installation
To install the script, add: importScript('User:Alex 21/script-functions.js'); importScript('User:Alex 21/script-references.js'); to Special:MyPage/common.js.

Usage
There will be a "Sort references" link in the toolbox on the left on every article under "Tools". Upon clicking the link, the references will be sorted accordingly; make sure to use the "Show preview" or "Show changes" buttons to make sure all edits are working. Any unnamed references are included with this move, and are provided with a newly-generated reference name in the format [website name] + [date month] + [date year] (e.g. "VarietySeptember2023", then "VarietySeptember2023-2", "VarietySeptember2023-3", etc. for any further articles from Variety posted in September 2023).

All references will be sorted by date. Any checks for dates (to sort the references and to rename unnamed references) will check for any date parameters in decreasing order of importance; this order, from highest to lowest, is date, archive-date, access-date.

If the beginning wikicode looks like this:

 By May 2020, a Disney+ series based on Percy Jackson was in the works, with the first season set to adapt the first book in the series, The Lightning Thief. Riordan revealed in March 2021 that searches for the series' directors and cast was underway, with James Bobin was announced as the pilot episode's director in October. Jonathan E. Steinberg and Dan Shotz were also announced as showrunners in July.

Then the end result will look something like this:

 By May 2020, a Disney+ series based on Percy Jackson was in the works, with the first season set to adapt the first book in the series, The Lightning Thief. Riordan revealed in March 2021 that searches for the series' directors and cast was underway, with James Bobin was announced as the pilot episode's director in October. Jonathan E. Steinberg and Dan Shotz were also announced as showrunners in July.

...

Bugs
This script will not function properly if a references has a newline within it; i.e. if the references spans more than one line in the editor. Make sure all individual references are on the same line.

Please report any other bugs on the talk page of the script's creator.