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:40, 24 April 2009 (documentation for user:js/urldecoder.js (still in development at the moment)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
urldecoder
Browsers *
Skins *
Code urldecoder.js
Released April 24, 2009; 16 years ago (2009-04-24)
Updated April 24, 2009; 16 years ago (2009-04-24)
Developer   AlexSm

 %% 

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

urldecoder is a script that converts URLs into internal links: paste

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

into the editing window, press the button and you'll get

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


Other features

  • the script recognizes most Wikimedia projects and bugzilla links;
  • you can also type the link description, and then press the button:
    http://de.wikipedia.org/wiki/Ding this page|[[:de:Ding|this page]]
  • you can select some text and the script will convert all URLs inside;
  • URLs from secure login browsing will be converted to normal links;
  • URLs will be percent-decoded from %-sequences into normal chars:
    http://…a20%26b|http://…a_&b
    this is tremendously useful in non-Latin language projects where most URLs look like %D1%EB%F3%E6…


Installation

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


Optional parameters

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


Localization

The script should work in all Wikimedia projects out of the box.

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. It's recommended that you add this code into you monobook.js in your local project. This will allow the script to avoid API requests and should save you and Wikimedia Foundation some traffic.