User:Opencooper/domainRedirect

__INDEX__ domainRedirect.js helps you create redirects from a subject's domain name to its article. For example, nytimes.com should redirect to The New York Times. Normally, you'd have to enter the domain into the search box to check if a redirect exists, then hunt around to find the domain which should redirect, and manually go through each step of creating the redirect. This script makes it simple by automating all that and letting you easily create these kinds of redirects if they need to be.

Installation
To install the script, add the following to your common.js page:

Styling
Domains that are subdomains (foo.bar.com) or subpages (foo.com/bar) are ignored. These can be shown by adding the following to your common.css:

Functionality
If a redirect already exists, nothing is shown since there isn't anything for you to do. If it finds a possible candidate for a redirect, it will show a message under the title stating "(Possible domain redirect: example.com)". If you hover over the link, it will tell you where it got that candidate from. Clicking "+" will easily allow you to create the redirect, leading you to a new page that is already pre-filled (see preload) and just has to be submitted.

The candidates are determined in the following order:


 * 1) The official website property on the page's Wikidata item
 * 2) From the infobox:
 * 3) Any link inside of the url template
 * 4) The website parameter of the infobox
 * 5) From the external links section:
 * 6) The first official website
 * 7) The first external link with "official" in its label

The third method can especially result in false positives, which is why these are only candidates and the creation of the redirect is up to you. Lastly, it might not always make sense for a specific domain to redirect to the subject, especially if it's not something one would search with. If you want to see whether a domain was failed to be found, ignored, or already exists as a redirect, you can check your browser's console.

License
This script and any associated files are licensed under Creative Commons Zero.