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 15:52, 25 April 2009 (improvements and corrections). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
urldecoder
Browsers *
Skins *
Code urldecoder.js
Released April 24, 2009; 16 years ago (2009-04-24)
Updated April 25, 2009; 16 years ago (2009-04-25)
Developer   AlexSm

 →[[]] 

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

urldecoder is a script that converts URLs to internal links:
you can paste URL into the editing window

http://meta.wikimedia.org/wiki/Meta:Babel#Spam_links|

then press the button (see pic on the right) and you'll get

[[meta:Meta:Babel#Spam links]]


Features

  • you can also type the link description, and then press the button:
    http://de.wikipedia.org/wiki/Ding this page|[[:de:Ding|this page]]
  • URLs from secure login browsing will be converted to normal links;
  • URLs to bugzilla bugs will be converted into [[mediazilla:...]]
  • URLs 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…
  • the script can also simplify all URLs in the selected text.


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