User talk:Splarka/wikialink.js

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Basics[edit]

Originally for adding personal links on every page on Wikipedia to specific Wikia wikis of the same page name.

Has been expanded to work: from almost any wiki, linking to almost any website that takes a urlencoded parameter, and in four navigational areas (actions, personal, toolbox, and navigation).

Usage[edit]

Most basic usage is (simply add to your monobook.js on this or another mediawiki wiki):

function wikiabuttons() {
    // instructions: http://en.wikipedia.org/w/index.php?title=User_talk:Splarka/wikialink.js
    addwb("action","wikia","www.wikia.com/wiki/","");
}

document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Splarka/wikialink.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

For the function addwb():

  1. The first parameter determines where to add the function. Valid attributes are "action" "navigation" "personal" "toolbox" (anything else defaults to "action")
  2. The second parameter determines the label of the link.
  3. The third parameter determines the link (domain etc). Omit "http://".
  4. The fourth parameter optionally sets an accesskey (leave as "" in most cases). If you wish to set one, it is advised to set it to one of the following free (generally) accesskeys: 1234567890bg`';-[].

So for example, addwb("action","wikia","www.wikia.com/wiki/","") adds an action button named [Wikia] to every page, and links it to www.wikia.com/wiki/ + the full page name (Note: "Editing " is removed on edit pages).

A more advanced implementation might be:

function wikiabuttons() {
    // instructions: http://en.wikipedia.org/w/index.php?title=User_talk:Splarka/wikialink.js
    addwb("toolbox","wikia","www.wikia.com/wiki/","");
    addwb("toolbox","wikifur","furry.wikia.com/wiki/","");
    addwb("toolbox","world","world.wikia.com/wiki/","");
    addwb("toolbox","uncyclopedia","uncyclopedia.org/wiki/","");
    addwb("toolbox","google","www.google.com/search?q=","");
}

document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Splarka/wikialink.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

Note that the action buttons build up fast, so this example used the toolbox instead. You can mix and match them as you wish. Like:

    addwb("toolbox","wikia","www.wikia.com/wiki/","");
    addwb("personal","wikifur","furry.wikia.com/wiki/","");
    addwb("action","world","world.wikia.com/wiki/","");
    addwb("navigation","uncyclopedia","uncyclopedia.org/wiki/","");
    addwb("toolbox","google","www.google.com/search?q=","");


Afterthought[edit]

Suggestions for non-breaking improvements cheerfully tested. I am not the best javacsript coder I know, but javascript is evil, so shush. Some thoughts on what could be improved:

  • Array elements instead of function calls
  • Ability to add to any menu (other languages, custom boxes), Problem: getElementById() only apparently works with literal strings in some browsers.