Jump to content

user:js/urldecoder

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Alex Smotrov (talk | contribs) at 22:38, 20 August 2009 (some improvements). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

urldecoder is a script to simplify entered URLs:

 →[[]] 

 [http://meta.wikime…
 [[meta:Page]]

urldecoder
Browsers *
Skins *
Code urldecoder.js
Released April 24, 2009; 16 years ago (2009-04-24)
Updated August 20, 2009; 15 years ago (2009-08-20)
Developer   AlexSm
  • paste your link into the editing window
  • after space type the link name (if needed)
  • press the button (see pic)


The script will automatically add brackets to form an external link and, if possible, will convert it into internal link:

http://de.wikipedia.org/wiki/Ding this page|

[[:de:Ding|this page]]


Features

  • While trying to convert the link into InterWikimedia link, the script will recognize all multilingual projects (Wikipedia, Wiktionary, etc.) and also Meta, MediaWiki, Commons and MediaZilla.
  • URL from secure login browsing will be converted to normal link;
  • URL will also be percent-decoded from %-sequences into normal chars:
    http://…a%26bhttp://…a&b
    this is tremendously useful in non-Latin language projects where most URLs look like %D1%EB%F3%E6…
  • By selecting some text and then pressing the button you can simplify all URLs inside.

Installation

  • English Wikipedia:
    importScript('user:js/urldecoder.js')your monobook.js
  • Other Wikimedia projects:
    importScriptURI('http://en.wikipedia.org/w/index.php?title=user:js/urldecoder.js&action=raw&ctype=text/javascript')


Localization

The script should work in all Wikimedia projects.

However, in non-English projects it has to make an extra API request each time to get the list of local namespaces. This is neccessary to correctly convert URLs into [[:File:X]] and [[:Category:X]] with leading colon.

Every time the script makes API request it displays the string with some code, for example for Polish Wikipedia:

 urlDecoderNS = {'pl':'plik|kategoria|image|grafika'}

It is recommended that you add this code into your monobook.js in your local project. This will allow the script to avoid API requests and should save you some traffic.


Optional parameters

urlDecoderKey = 'c' //accesskey
urlDecoderIntLinks = true //also decode existing [[internal links]] in selected text