Jump to content

User:Xover/EasyLinks

From Wikipedia, the free encyclopedia
EasyLinks
DescriptionEasily get proper wikilinks for diffs, specific page revisions, and sections.
Author(s)Xover
StatusBeta
Version1.0b1
UpdatedJanuary 16, 2022; 2 years ago
Skins
  • Vector
  • ? Monobook
  • ? Modern
  • ? Timeless
  • ? Cologne Blue
  • ? MinervaNeue
SourceUser:Xover/EasyLinks.js

EasyLinks is a user script that provides an easy way to get an internal wikilink to diffs, a specific revision, or a section without having to dig up URL parameters and section titles, converting syntax variants, or figuring out obscure templates. If supported by your browser it will attempt to place the link directly into your clipboard, otherwiise it will give you a dialog box where you can manually copy the link. All links will be proper wikilinks so you can use them anywhere, and anyhow, you would use any other internal link.

Installation

[edit]

EasyLinks[1] (source)

If you have Equazcion's ScriptInstaller installed you should be able to just clink the "Install" link above. If you don't have it then go get it right away (you can thank me later) or follow the instructions in the footnote just below.

Manual install

  1. ^ Copy the following code, edit your user JavaScript, then paste:
    {{subst:lusc|1=User:Xover/EasyLinks.js}}

Why EasyLinks?

[edit]

Have you ever tried to link to a diff? Including diffs is often the best way to communicate something, and in some circumstances it is required by policy. And yet to get a diff link you have to go digging through the URL in the page address for the right parameter, somehow figure out where the right special page is, or take a doctorate on the finer points of {{diff}}, {{diff2}}, {{diff3}}, {{diff4}} and the half dozen other templates for this. Most people don't bother and just post the full URL as an external link. The same problem applies for linking to a specific revision of a page, or a section of a page, or, worse still, a section in a specific revision of a page (a talk page that is frequently archived, for example). People either simply do not do these things, waste a lot of time on doing it, or do it in ways that have problems or limitations (like using external link syntax for internal wikilinks).

What's it do?

[edit]

EasyLinks gives you some extra functions in the page actions bar (the stuff on the same line as the "Article", "Talk", "Edit", and "History" tabs at the top of the page) and on each section title right next to the "Edit" and "Edit source" (if Visual Editor is enabled). The current list of functions is:

  • Get diff link (page actions, only on diff pages)
  • Get permanent link (page actions, gets latest revision by default)
  • Get section link (section header)
  • Get permanent section link (section header, gets latest revision by default)

Diff links will be of the form [[Special:Diff/123456|123456]]; links to a specific revision [[Special:PermanentLink/123456|123456]]; a section [[Page Name#html id of anchor|section title]]; and for a section on a specific revision [[Special:PermanentLink/123456#html id of anchor|section title]]. All functions related to a specific revision will use the currently selected revision if present and the latest revision of the page at the time the function is invoked otherwise.

Since the links are ordinary wikilinks they can be used the same way as any other wikilink. In particular, you can (of course) change the bit after the pipe: [[Special:Diff/123456|lookit mah leet editing skillzzz!!!]].

EasyLinks will pop up a message dialog with a text field containing the link, and if your web browser supports it will automatically select the text, copy it into your clipboard, and then close the dialog. If this fails you'll have to copy the link manually and dismiss the dialog yourself. There's a new specification for a web "Clipboard API", but no web browsers actually support it yet so for now you'll have to live with the somewhat inelegant approach.

Browser and skin support

[edit]

Right now EasyLinks has only been tested in Safari 12.1 and the Vector skin, but there's no particular reason it shouldn't work in most skins and most modern browsers. The automatic copying relies on JavaScript features that are relatively new and may not work in slightly older browsers, but the fallback to providing the link for manual copying should work regardless. If you try EasyLinks in anything other than Safari and Vector I would really appreciate if you let me know whether it worked or not.

Limitations and technical details

[edit]

The various diff templates support a lot of stuff like linking to a diff between two arbitrary revisions of a page that EasyLinks does not handle. If you need any of those features (most people don't in most situations) you'll need to use the templates.

EssyLinks relies on picking &diff= and &oldid= out of the URL, falling back to wgCurRevisionId for revisions when the URL parameter isn't present. These will not always be present for all types of diff pages and the copied link will be broken. It is techniically possible to fix at least some of these cases, but that hasn't been implemented yet and may be technically impractical to do. EasyLinks mostly tries to make the easy cases easy, so the complicated cases may require manual handling.

Feedback

[edit]

If you use EasyLinks I would appreciate feedback on how it works for you, suggestions for changes, and especially bug reports when it fails. The script was primarily written to make my own life easier, so it may not necessarily interact well with your editing, but I'm always grateful for suggestions to improve it. For now you can leave such feedback at User_talk:Xover.