Uncyclopedia:Hacks

From Uncyclopedia, the content-free encyclopedia
(Redirected from UN:HAX)
Jump to navigation Jump to search

Hacks to circumvent existing restrictions of the MediaWiki software are numerous on Uncyclopedia due to its parody nature. They are sorted by the magnitude of intervention, from custom tags to site-wide CSS hacks to in-place CSS/template magic.

Useful page-coding techniques

This section describes specialized code (tags and templates) that anyone can put in any Uncyclopedia article. The results of this coding are visible to everyone who reads the page, without any special arrangements.

Random choice tag

The <choose> tag permits different strings to be assembled onto the page each different time someone calls it up. A typical use is as follows:

<choose>
<option>Text1</option>
<option>Text2</option>
<option weight=5>Text3</option>
</choose>

Every time the page is loaded, the entire <choose> tag is replaced with the string inside one of the <option> tags. Options with a greater weight have a greater chance of popping up. If an option has no weight, 1 is assumed. In the example above, Text3 (with weight=5) would pop up 5/7 of the time.

Dynamic Page List (DPL)

Dynamic Page List (DPL) is a MediaWiki extension that provides an easy way to make an Uncyclopedia page contain a list of other pages. It is used for the directories at UnNews and at the Village Dump. It has the following syntax:

<DynamicPageList>
namespace=NAMESPACE
category=CATEGORY
shownamespace=true (or false)
mode=ordered (or unordered)
suppresserrors=true (or false)
</DynamicPageList>

This tag gets page titles in the specified namespace and category and pastes them as a numbered/bulleted (controlled by the ordered parameter) list. This example lists all articles from Category:Encyclopedias in an ordered and unordered fashion. (It is a table with a dynamic page list tag in both cells.)

  1. Encyclopedia
  2. Moby-Dick
  3. Encyclopædia Britannica

Forum tag

The <forum> tag is another MediaWiki extension comparable to DPL (see above), except that <forum> displays more information about the entries. The tag is used in Forum:Index (in fact, the tag should be used only on forum pages, or in Uncyclopedia:Maintenance, or Template:Oldcatlist).

Title override

Many Uncyclopedians want to pun with the title of a page. For example, the article on El Salvador calls the country "El Humidor". Unfortunately, no reader will look up "El Humidor" in our encyclopedia. Making that the page name means the reader must guess the punch line before he can read the joke! The solution is for the page to be named El Salvador but have it change its own title to read "El Humidor". It does so by beginning with the following template:

 {{Title|El Humidor}}

Usage: {{title|new title|align=ALIGNMENT}}. This page uses title|align=center as an example. Both parameters are optional.

The transformation of a page's displayed title is done by site-wide JavaScript.

Conditional templates

These templates and parser functions output values only when certain conditions are met.

  • {{#if:condition|text|alternate text}}
  • {{#switch:key|a=value|b=value|...|#default=value}}
  • {{ifie|text}}
  • {{ifnotie|text}}
  • {{if page exists|page|text|alternate text}}

The if template outputs the text if "condition" is not an empty string; otherwise, it outputs the alternate text. The ifie/ifnotie templates output the text if the user is/isn't using Internet Explorer.

This is only shown in IE.
This is only shown in browsers with better CSS support, such as Opera and Firefox.

Use {{if page exists}} instead of the built-in {{#ifexist:…}}, because {{if page exists}} does not constitute an attempt to reference the page. If you used #ifexist: on a non-existent page, Uncyclopedia would record (at Special:WantedPages) that someone was asking for the page to be created, which is probably not true.

There exist tag-like versions of ifie/ifnotie for those who need advanced formatting (if one tries adding HTML attributes in a template parameter, the entire parameter gets stripped). Usage:

  • {{ie-begin}}text{{ie-end}}
  • {{notie-begin}}text{{notie-end}}
Nuvola apps important.svg
This box is only visible in IE.
Nuvola apps important green.svg
This box is only visible in browsers with better CSS support.

Hidden text

Placing text in a <div> with class="sigexpand" marks a region for the reader to hover the pointer over; within that <div>, another <div> with class="sighidden" brackets text that will appear when the pointer does hover there.

The most common case of this is in signatures. UN:SIG requires that signatures not hog a lot of space on the page, but you are allowed to display whatever you want if the reader hovers over a part of your signature.

For example, this code:

<span class="sigexpand">Sig<span class="sighidden">nature</span></span>

turns to:

Signature

Fake links

These come in three flavors:

These fully-realistic imitations look like this, this, and this (the only exception is fakeexternallink, which uses hover-text to imply where the external link would go). They can be used to prank without registering the links in Special:WhatLinksHere, Special:LinkSearch, or Special:WantedPages.

Try to keep it funny and not just annoying.

Site-wide CSS hacks

These are managed via MediaWiki:<skin name>.css (for skin-specific hacks; replace <skin name> with the name of any skin) and MediaWiki:Common.css (for site-wide hacks).

Non-white image frames

Normally, if a thumb/frame image is placed on a non-white background, the result is crappy. To circumvent default MediaWiki behavior, transclude the image in a nonwhite class div, like this:

<div class="nonwhite">[[Image:File.ext|thumb|Description]]</div>

This table shows the difference. The left column uses the default MediaWiki rules, while the right column uses the hack.

Uncyclopedia logo
Uncyclopedia logo

This has also been replicated in {{ImageNW}}.

Underlined and non-underlined links

Traditionally, wikilinks are not underlined if viewed by an anonymous user and underlined if viewed by a registered user. However, some pages may require this convention to be overridden. If class="(no)underlinelink" is applied to an HTML element — like a span, div, table or column — it will make all links inside that element (non-)underlined.

This column uses default behavior for links.

Stealth external links

Mostly used for Template:User, this class allows external links to appear almost exactly like wikilinks. (Links to Uncyclopedia that use query strings, as well as links to websites for which we have interwiki prefixes, already look just like internal links, so this class will have no effect there.) This class can be used in table, div, span, tt, etc.

normal class="plainlinks" class="stealthexternallink"
Wiki link
External link
Interwiki link
Broken link

New

Also, class="new" changes wikilinks to look like red (broken) links:

normal class="new"
Wiki link
Broken link
Wiki link
Broken link

Custom Logos

You can change the Uncyclopedia logo at the upper left corner by using the {{Logo}} template. For example:

{{logo|image=Name of graphic.jpg|size=160px|top=0}}

After image=, type the name of the graphic, including its file type (extension), such as .jpg or .JPG or .png. After size=, type the desired width of the logo in pixels (px).

If you have your own plans for that real estate, you can make the Uncyclopedia logo go away without adding one of your own by using {{Nologo}}.

More extensive changes to the formatting for a specific page would require changes in the website CSS style rules, which would slightly slow down even users who aren't interested in the page in question. Therefore, this method is discouraged for individual pages, but is done for certain entire namespaces, by writing a rule with a selector like this:

body[class=ns-0] #p-logo a

You can suggest new logos for namespaces at Uncyclopedia:Logos.

"Buttons"

Here is a stupid little piece of code to make clickish-able buttons in some browsers (click the mouse button down and hold it, in Mozilla and Opera maybe):

Clickable link


Just text

You can define any border color/width, font, or background color you like. Just do not define a border-style in the text (the css swaps it from outset to inset) or it will not be changed.

Note: Recently changed from :hover to :active, more akin to a form button)

This technique is used in the template {{Keypress}}.

Find and greet noobs

If you are a greeter whore (the type who likes to subst: in {{Welcome}} to aim for the top of Special:Mostlinked), this little trick will show missing talk pages for logged in users bold bright green (in Mozilla and maybe Opera) in recent changes. Just add it to your css:

ul.special li a[title ^="User talk:"].new { color:#00ff00;font-weight:bold }
ul.special li a[title ="Special:Contributions"] + a[title ^="User talk:"].new { color:#CC2200;font-weight:normal }

The first line triggers for all missing (class="new") User_talk: links on Recent Changes (and some other special pages). The second line triggers for all anonymous IP talk pages (which you don't want to greet). Therefore, if you tweak the styles of the first line, you should undo any tweaks in the second to reduce false positives. Eg: { color:#00ff00;border:2px dashed red;background-color:pink;text-decoration:blink; } and { color:#CC2200;border:none;background-color:transparent;text-decoration:none; }

Hiding/showing stuff

You can add code to your user uncyclopedia.css and show or hide many features, if you so desire. Here are some you may wish to adjust:

Scores

In {{S}} (used in some other templates) and {{vfp}}, there are (optionally somtimes) score boxes to tally votes. For some people who tally votes this can be distracting. To hide these you can use:

.scorebox {display: none;}

VFH

In {{VFH}}, there is a hidden (by default) div which shows the appropriate code for placing {{FA}} (the featured-article template, including date and link to 'featured' version). You can display it with:

.featurecode {display: inline;}

Hacks that require changes to your CSS at Uncyclopedia

A Cascading Style Sheet (CSS) file contains any special orders on the appearance of objects in pages. You can change how Uncyclopedia renders pages to you by editing your CSS file on Uncyclopedia. This file is named:

 User:<insert name here>/common.css

You can edit it by clicking here.

Administrators listed in boldface in reports

You can get the names of the administrators to display in bold in reports. The code is in the file MediaWiki:Admin names in bold.css. If you want this effect, do one of the following:

  1. Copy the following text: @import url("http://uncyclopedia.ca/index.php?title=MediaWiki:Admin_names_in_bold.css&action=raw&ctype=text/css"); and paste it at the start of your style sheet (located here). Or
  2. Open MediaWiki:Admin names in bold.css, copy its entire contents, and past them at the start of any line in your style sheet. Or
  3. Instead of storing the list in your userspace on Uncyclopedia, you could store it on your computer. For example, if you use Firefox, you could paste the CSS code into your userContent file.

Options 2 and 3 give you more control, but won't pick up any changes to the list of administrators that are made later.

The code you are copying or importing contains a list of CSS selectors, one for each current administrator, each in this form:

a.mw-userlink[title="User:name-of-one-administrator"],

At the end of the list, bold is specified. If you have copied the list into your own file and if you understand CSS, then instead of bold, you could substitute an effect that you prefer, such as a use of a specific color.

This hack takes effect anywhere MediaWiki knows it has coded an anchor to a user page. This includes Special:RecentChanges, your Special:Watchlist, and any table that compares two versions of an individual file.

Restoring MonoBook viewing

These instructions were added after our former host Wikia/FANDOM deprecated the MonoBook skin we use to imitate Wikipedia. This procedure is no longer required.
  1. Right-click on Uncyclopedia and select Inspect or something similiar.
  2. Find the JS console.
  3. Type document.cookie = "useskin=monobook; expires=01 Jan 2100 00:00:00 GMT; path=/" into the console.
  4. Refresh cache. It depends what browser you are using.
  5. Done!
  6. Alternatively, navigate to your style sheet (located here)
  7. Edit the style sheet in source mode
  8. Insert the line document.cookie = "useskin=monobook; expires=01 Jan 2100 00:00:00 GMT; path=/"
  9. Save the page.
  10. Refresh your browser cache.
  11. You should now be able to view subcategories when you navigate to a category page.

Your personal JavaScript file

Personal JavaScript files contain commands in the JavaScript language that take effect whenever Uncyclopedia renders a page for display to you. (You cannot control Uncyclopedia's behavior toward other users.) This file is named:

 User:<insert name here>/common.js

You can edit it by clicking here.

JavaScript might be switched off in your web browser. None of the files and hacks described in this section have effect unless you switch JavaScript on.

Uncyclopedia can operate under several different skins. Most everyone uses the vector skin, because it lets Uncyclopedia do the best imitation of Wikipedia.

JavaScript specific to one skin can be placed in a file by that name. For example, most people enable the hacks described below by adding lines to:

 User:<insert name here>/vector.js

You can edit it by clicking here. If you were to switch to a different skin, these selections would no longer take effect.

Your name in reports

User names in special pages are followed by the legend "(talk | contribs)" that let you see the user's talk page and contributions with one click. It may seem stupid to have this legend follow your own name; after all, there are My talk and My contributions buttons on the top of every page. You can remove this legend from all special pages, to make the reports simpler, by adding the following to your personal JavaScript file on Uncyclopedia:

if ( !wgIsArticle ) {
   $("a.mw-userlink[title='User:<insert name here>']+span.mw-usertoollinks").remove();
}

Rollback tools

Uncyclopedian vandalism police (with the rollback permission) see a "rollback" legend in diffs and at Special:RecentChanges. This lets them quickly revert an edit or a string of consecutive edits by the same user. The benefits over Undo are:

  • Rollback works with a single click.
  • Rollback marks the rolled-back edit(s) as "patrolled." With Undo, you have to mark each edit manually so other patrollers don't review the edit(s) again.
  • Rollback doesn't open an edit window.
  • Undo is a regular edit that adds the article to your Watchlist (though you can set My preferences so that editing an article doesn't automatically add it to your Watchlist).

The liabilities are:

  • You sometimes roll back more than you intended; for example, when looking at a RecentChanges listing that doesn't go all the way back.
  • You can't write a Change Summary.

As registered Uncyclopedians are usually entitled to an explanation when their edits are undone (and it is neighborly to give even Anon a reason), this problem disqualifies Rollback for many uses.

Custom change summary

Fortunately, there is a JavaScript that opens a window to ask you for a Change Summary. To enable this feature, add the following line to your personal JavaScript file on Uncyclopedia:

importScript( "User:Furry/customRollback.js" );
Custom options

You can invoke the JavaScript with a configuration variable in your personal JavaScript file:

window.furry          = {};
window.furry.rollback = {
  allowNoSummary: false,
  addNewLink: false,
  useAjax: true,
  removeLinkClass: false
  };
importScript( "User:Furry/customRollback.js" );

If you use the configuration file, then on the second line,

  • Setting allowNoSummary to true lets you opt out of writing a Change Summary.
  • Setting useAjax to false jumps to the "Rollback succeeded" page after a successful rollback, as is the case if you don't use the script at all. Otherwise, the script simply modifies the listing you were viewing. ("ajax" is "Asynchronous JavaScript and XML," the technology that lets programs modify a web page without reloading it.)
  • Setting addNewLink to true gives you both the usual rollback button and a "rollback (custom summary)" button. In this case, only the latter button asks you to type a Summary.
  • Setting removeLinkClass to true removes the mw-rollback-link for the parent span element of the rollback link(s). If you have local CSS code to change the appearance of the Rollback button, this step cancels that change, once the edit is rolled back.

Rollback all

To deal with obvious vandals, adding the following line to your personal JavaScript file adds a Rollback all button to the top of each Special:Contributions page:

importScript( "User:SPIKE/RollbackAll.js" );

Clicking on Rollback all is like clicking the Rollback link for each of the vandal's contributions that is still shown as the most recent change (the "(top)" change) to the page. The new button shows you the count of Rollbacks that will be tried.

If the listing shows multiple edits to a page, there is no way to know whether they will also be rolled back without looking at the page's History to see if there were intervening edits by others. As the edits are rolled back, the lines in the Contributions listing are struck through. However, these other edits are not struck through, even if they are also rolled back. In addition, Rollback will not roll back a user's edits to a page the same user created and no one else has edited, nor will it undo a page move.

If you are an Admin, Rollback all marks each of your rollbacks as well as the original edit that is undone as a "bot edit." This removes the entire transaction from the listing of wiki activity at Special:RecentChanges unless the viewer selects "Show bot edits." This may be a way to spoil some of the vandal's sense of accomplishment.

Patrol tools

Omit separate confirmation page

For users with the Rollback privilege (see the preceding section), the Patrol button in Special:RecentChanges, in a diff report, or at the bottom of a new page, normally diverts your browser window from the page you were looking at to a confirmation page. The confirmation page gives you a one-click option to return to some page, which is often the right one.

To instead stay on the same page and simply replace the Rollback button with a legend ("Patrolled!"), add the following line to your personal JavaScript file on Uncyclopedia:

importScript( "User:Furry/ajaxPatrol.js" );

("ajax" is "Asynchronous JavaScript and XML," the technology that lets programs modify a web page without reloading it.)

Patrol multiple changes

If you add the following line to your personal JavaScript file on Uncyclopedia, items on Special:RecentChanges that describe multiple unpatrolled edits will include a clickable link "patrol" that marks each associated change as patrolled:

importScript( "User:Bizzeebeever/scripts/patrol.js" );

You will not see such a link if one of the edits was the creation of the page. In this case, click on + to expand the listing, then click on "patrol this page" in the bottom (oldest) entry in the expanded list. This will patrol the creation and any subsequent edit of the page.

Dynamic update

If you are staying up all night from caffeine and would like to see every edit to the wiki as it comes in: At My preferences, under Gadgets, there is an "interface gadget" that puts a Auto-update button on Special:RecentChanges. Click this button and the page will be refreshed every 15 seconds. If you have called for a shorter version of Special:RecentChanges (such as by appending ?limit=15 to see only the last 15 edits), this is what will be refreshed.

It looks like it's doing something smart, such as editing your listing, but it simply calls for a new copy of Special:RecentChanges and patches its innards into your browser window. "Grouped recent changes" and the Unwatch button (discussed below) are disabled after any refresh, because the code that does these things doesn't realize the list has been refreshed; you will always see edits sorted by time, not by pages edited. Once you turn on dynamic refresh, you can't turn it off except by reloading RecentChanges (such as by pressing F5).

"Unwatch" tool

The watchlist is a list of pages that should be of interest to you, such as pages you created or edited. It shows the most recent change to each one. Managing your watchlist is described at How pages work.

If you add the following line to your personal JavaScript file on Uncyclopedia, every line in your watchlist report will begin with a red button that you can click to instantly remove the page in question from your Watchlist.

importScript( "MediaWiki:Unwatch-Rewatch.js" );

The line in the watchlist is replaced by a confirmation, which has a button you can click to re-add the page to the watchlist.

The same thing will happen at Special:RecentChanges for entries that are on your watchlist.

See also