Guest

auscompgeek

By: a guest on Jun 30th, 2010  |  syntax: JavaScript  |  size: 28.84 KB  |  hits: 138  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. // ==UserScript==
  2. // @name                Simplepedia
  3. // @version             1.1
  4. // @namespace           http://userscripts.org/scripts/show/42312
  5. // @description         MediaWiki beautification
  6. // @author              Grant Stavely http://grantstavely.com/
  7. // @copyright           2009+ Grant Stavely
  8. // @license             (CC) Attribution Non-Commercial Share Alike; http://creativecommons.org/licenses/by-nc-sa/3.0/
  9. // @include             http://*
  10. // @include             https://*
  11. // @exclude             *google.*
  12. // @exclude             *userscripts.org/*
  13. // @contributor         http://userscripts.org/users/auscompgeek
  14. // @contributor         http://userscripts.org/users/sizzle
  15. // @contributor         http://userscripts.org/users/67105
  16. // @contributor         http://www.howtocreate.co.uk/bio.html
  17. // ==/UserScript==
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // GreaseKit, Opera users: This version does not have any dependancies.
  20. ////////////////////////////////////////////////////////////////////////////////
  21. (function () {
  22.         // User Options are below. If you are using Firefox, please use about:config to change these
  23.         // For Greasekit users, skip down to the next section
  24.         if (navigator.userAgent.match("Gecko") && typeof GM_getValue == "function" && typeof GM_setValue == "function") {
  25.                 // Heading font?
  26.                 if (GM_getValue("headingFont") == undefined) {
  27.                         // Use the full name of the font you would like
  28.                         // I suggest 'Helvetica Neue' or 'Hoeflter Text'
  29.                         GM_setValue("headingFont", "'Helvetica Neue', Helvetica, 'MgOpen Moderna', sans-serif");
  30.                         //GM_setValue("headingFont", "'Hoefler Text', 'Times New Roman', Times, serif");
  31.                 }
  32.                 // Here you can set the font that most of the site will use
  33.                 if (GM_getValue("bodyFont") == undefined) {
  34.                         GM_setValue("bodyFont", "'Helvetica Neue', Helvetica, 'MgOpen Moderna', sans-serif");
  35.                         //GM_setValue("bodyFont", "'Times New Roman', Georgia, Times, serif");
  36.                 }
  37.                 // Show login, edit-page, and other metadata tabs
  38.                 if (GM_getValue("user") == undefined) {
  39.                         // boolean true/false
  40.                         GM_setValue("user", false);
  41.                 }
  42.                 // Link color!
  43.                 if (GM_getValue("color") == undefined) {
  44.                         // use a css compatible value "#ff0000", "#f00", "red", and so on...
  45.                         GM_setValue("color", "#0892D0");
  46.                 }
  47.                 // Stub link color!
  48.                 if (GM_getValue("stubColor") == undefined) {
  49.                         GM_setValue("stubColor", "pink");
  50.                 }
  51.                 // Red (unwritten articles) link color!
  52.                 if (GM_getValue("newColor") == undefined) {
  53.                         GM_setValue("newColor", "red")
  54.                 }
  55.                 // Language settings are persistent, but you can give it a default if you like
  56.                 if (GM_getValue("default_language") == undefined) {
  57.                         // string value of wikipedia subdomains: http://meta.wikimedia.org/wiki/List_of_Wikipedias
  58.                         // "en", "fr", "gr", etc...
  59.                         GM_setValue("default_language", "en");
  60.                 }
  61.                 // Show a selection list of all alternate language versions of any document
  62.                 // Wikipedia specific
  63.                 if (GM_getValue("international") == undefined) {
  64.                         // boolean true/false
  65.                         GM_setValue("international", false);
  66.                 }
  67.                 // Now throw all our prefs into an object
  68.                 var prefs = {
  69.                         headingFont: GM_getValue("headingFont"),
  70.                         bodyFont: GM_getValue("bodyFont"),
  71.                         user: GM_getValue("user"),
  72.                         color: GM_getValue("color"),
  73.                         stubColor: GM_getValue("stubColor"),
  74.                         newColor: GM_getValue("newColor"),
  75.                         defaultLanguage: GM_getValue("default_language"),
  76.                         international: GM_getValue("international")
  77.                 }
  78.         } else {
  79.                 // Omniweb, Safari, etc users:
  80.                 // Greasekit lacks an about:config, so make your changes here
  81.                 var prefs = {
  82.                         headingFont: "'Helvetica Neue', Helvetica, 'MgOpen Moderna', sans-serif",
  83.                         //headingFont: "'Hoefler Text', 'Times New Roman', Times, serif",
  84.                         bodyFont: "'Helvetica Neue', Helvetica, 'MgOpen Moderna', sans-serif",
  85.                         //bodyFont: "'Times New Roman', Georgia, Times, serif",
  86.                         user: false,
  87.                         color: "#0892D0",
  88.                         stubColor: "pink",
  89.                         newColor: "red",
  90.                         defaultLanguage: "en",
  91.                         international: false
  92.                 }
  93.         }
  94.         ////////////////////////////////////////////////////////////////////////////////
  95.         // If the site has a monobook css link, it's a witch
  96.         // If the site imports monobook css using a hack, it's Wikipedia
  97.         // If the site defines a skin variable, it is also ugly
  98.         var wiki = false,
  99.                 cssLinks = document.getElementsByTagName("link"),
  100.                 inlineStyle = document.getElementsByTagName("style");
  101.         if (skin == "monobook" || location.href.match(/wiki/i)) { // The site says that we're in a wiki
  102.                 wiki = true;
  103.         } else { // We're not sure yet, we have to figure it out
  104.                 for (var i = cssLinks.length -1; i >= 0; i--) {
  105.                         var cssLink = cssLinks[i].getAttribute("href");
  106.                         if (cssLink.match(/monobook/i)) {
  107.                                 wiki = true;
  108.                         }
  109.                 }
  110.                 for (var i = inlineStyle.length -1; i >= 0; i--) {
  111.                         var style = inlineStyle[i].childNodes[0].data;
  112.                         if (style.match(/monobook|wiki/i)) {
  113.                                 wiki = true;
  114.                         }
  115.                 }
  116.         }
  117.         if (!wiki) return; // Make sure we only run on wikis
  118.         ////////////////////////////////////////////////////////////////////////////////
  119.         // Make sure that we can style everything properly.
  120.         if (typeof GM_addStyle != "function") {
  121.                 function GM_addStyle(css) {
  122.                         if (typeof addStyle == "function") {
  123.                                 addStyle(css);
  124.                         } else if (typeof PRO_addStyle == "function") {
  125.                                 PRO_addStyle(css);
  126.                         } else {
  127.                                 var heads = document.getElementsByTagName("head");
  128.                                 if (heads.length > 0) {
  129.                                         var node = document.createElement("style");
  130.                                         node.type = "text/css";
  131.                                         node.appendChild(document.createTextNode(css));
  132.                                         heads[0].appendChild(node);
  133.                                 }
  134.                         }
  135.                 }
  136.         }
  137.         ////////////////////////////////////////////////////////////////////////////////
  138.         // Away we go
  139.         try {
  140.                 GM_addStyle("body,p{background-color:inherit!important;color:#000!important;font-size:13px;line-height:18px;background-image:none}span,div{border:none!important;background-color:inherit!important;color:#000!important;font-size:inherit!important;line-height:inherit!important}.toctext:hover,toclevel-1:hover,.toclinks:hover,a:hover{color:#000!important}a:active{color:#000!important}b{color:#000}h1,h2,h3,h4,h5{background-image:none!important;background-color:transparent!important;-webkit-background-clip:none!important;-webkit-background-origin:none!important;font-weight:bold!important;color:#000!important;border-bottom:#eee 1px solid!important;border-top:none!important;border-left:none!important;border-right:none!important}h1{font-size:24px!important}h2{font-size:150%!important}h3{font-size:120%!important}li,p,ul,blockquote{padding:5px!important;color:#000!important;background-color:inherit}ul,ul li{list-style-image:none!important;list-style-type:disc!important;list-style-position:outside!important}table{margin:0px!important;padding:3px!important;background-color:#f6f6f6!important;color:#000;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;border:1px solid #eaeaea!important;border-collapse:inherit!important}th,tr,td,.thumbinner,.image{background-color:#f6f6f6!important;color:#000!important;border:none!important;padding:0px!important;margin:0px!important;border-collapse:inherit!important}ol{list-style-type:decimal!important;list-style-position:outside!important}.selected,pre{-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;border:1px solid #eaeaea!important}fieldset{-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;border:1px solid #eaeaea!important}.logotype,a.logotype:link,a.logotype:visited,a.logotype:active{font-weight:bold!important}#logotype{margin-top:180px}#logotype,#globeLogo,#front_search_bar{width:100%;text-align:center}#frontlogo{font-size:24px!important;color:#000!important;font-weight:bold!important;underline:none!important;padding-bottom:5px}#frontsearchInput{width:240px}#frontsearchbar{z-index:10000;height:100%;background-color:inherit!important;color:black;text-align:center}#front-search,#random-article{display:inline!important}#globalWrapper{position:absolute;left:0px;top:0px;z-index:50;border:none;margin:0px!important;padding:0px!important}#content{margin:0px!important;padding:0px!important;top:0px!important;position:absolute!important}#bodyContent{width:auto!important;margin:10px!important}#column-one,#column-content{margin:0px!important}#contentSub{margin-top:30px!important;margin-left:0px!important}#firstHeading{margin-top:15px!important;margin-left:15px!important;margin-bottom:0px!important}#mp-topbanner,#mp-topbanner table,#mp-topbanner tr,#mp-topbanner td,#mp-topbanner th,#mp-topbanner tbody{background-color:#fff!important}h2 .edisection,.editsection,.editsection a:link,.editsection a:visited,.editsection a:active{font-size:9px!important;color:#ddd!important;font-weight:normal!important}h2 .editsection:hover,.editsection  a:hover{color:#000!important}.smallcaps{font-variant:small-caps!important;font-size:70%;color:#0892D0!important}.relarticle,.mainarticle{color:#000!important;background-color:inherit!important}.toclevel-1,.toclevel-2,.toclevel-3,.toclevel-4{list-style:none!important}.topicon,#featured-star,#protected-icon,#protected-icon div,#speak-icon,#spoken-icon,#spoken-icon div{display:none!important}.dablink{padding-top:0px!important;padding-left:10px!important}.printfooter{padding-top:10px!important}#edit-ul{position:relative;float:right;margin:0px}#p-cactcions,#ca-nstab-citations,#ca-nstab-citations a,#ca-move,#ca-move a,#ca-nstab-portal,#ca-nstab-portal a,#ca-nstab-main,#ca-nstab-main a,#ca-nstab-special,#ca-nstab-special a,#ca-nstab-category,#ca-nstab-category a,#ca-nstab-help,#ca-nstab-help a,#ca-nstab-user,#ca-nstab-user a,#ca-talk,#ca-talk a,#ca-edit,#ca-history,#ca-history a,#ca-addsection,#ca-addsection a,#ca-watch,#ca-watch a,#ca-viewsource,#ca-viewsource a,#ca-nstab-project,#ca-nstab-project a,#ca-nstab-image,#ca-nstab-image a{font-size:smaller!important;z-index:1500;color:#ddd!important;border:none!important;text-align:left!important;margin:0px!important;position:relative!important;background-color:transparent!important;font-weight:normal!important;padding-top:0px!important}#ca-nstab-main a:hover,#ca-nstab-special a:hover,#ca-nstab-category a:hover,#ca-nstab-help a:hover,#ca-nstab-user a:hover,#ca-talk a:hover,#ca-history a:hover,#ca-addsection a:hover,#ca-watch a:hover,#ca-viewsource a:hover,#ca-nstab-project a:hover{color:#000!important}#p-cactions li a,#p-cactions li.selected,#content div.thumb{background-color:transparent!important}#p-cactions{left:inherit!important;top:55px!important;right: 5px!important}.portlet{padding:0px!important;margin:0px!important}#p-personal{position:absolute!important;top:0px;right: 20px;font-size:smaller!important;margin-right: 20px!important;z-index:1500}#pt-login,#pt-login a{font-size:smaller!important;color:#ddd!important;position:relative;float:right;margin-right: 10px}#pt-login a:hover{color:#000!important}#pt-userpage a:link,#pt-mytalk a:link,#pt-preferences a:link,#pt-watchlist a:link,#pt-mycontris a:link,#pt-logout a:link{color:#ddd!important}#pt-userpage a:hover,#pt-mytalk a:hover,#pt-preferences a:hover,#pt-watchlist a:hover,#pt-mycontris a:hover,#pt-logout a:hover{color:#000!important}.pBody{padding-right: 20px!important}.pBody{}#p-personal li{background-image:none!important}#preftoc li{border-right: none!important;list-style-type:none!important;background-color:transparent!important}.toccolours,.navbox-abovebelow,.navbox-group,#toc,.nowraplinks,.collapsible,.autocollapse,#catlinks,.printfooter,.ambox,.ambox-content,.infobox,.geography,.vcard,.thumb,.tright,.mbox-text{margin:5px!important;background-color:#f6f6f6!important;color:#000;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;border:1px solid #eaeaea!important}tr,th,td,tbody,.toclevel-1,.toclevel-2,.toclevel-3{background-color:#f6f6f6!important;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;border:1px solid #f6f6f6!important;border-collapse:inherit!important;margin:0px!important}.toc:link,#toc:link,th:link,td:link,tbody:link{border-color:#ddd!important}th:hover,td:hover,tbody:hover{background-color:#eee!important;border-color:#ddd!important}.thumb:hover,.thumbcaption:hover,.thumbinner:hover{background-color:#eee!important;border-color:#ddd!important}th:hover,td:hover,tbody:hover,.thumb:hover,.thumbcaption:hover,.thumbinner:hover{background-color:#eee!important;border-color:#ddd!important}#toc ul:hover li,#toc ul:hover,#toc li:hover,.toclevel-1:hover,.toclevel-2:hover,.toclevel-3:hover{background-color:#eee!important;border-color:#eee!important}.wikitable,.prettytable{margin:0px 0px 0px 0px;background-color:#f6f6f6!important;color:#000;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;border:1px solid #eaeaea!important}td table{width:auto!important;background-color:transparent!important}#p-search{ display:block!important;position:absolute;top:20px;right: 10px;visibility: visible;z-index:1000;background-color:inherit;height:500px;color:#000}#langJump{z-index:100;position:absolute;top:30px;right: 220px}#floatingsearch{z-index:100;border:none;position:absolute;top:30px;right: 20px}#mp-upper,#mp-upper table,#mp-upper td,#mp-upper tr,#mp-upper th,#mp-upper tbody{z-index:0!important;margin-top:100px;background-color:#fff!important;border:none!important}#mp-newhead{margin-top:10px;margin-bottom:0.1em;line-height:2.0em}#mpheader{z-index:100!important;width:500px!important;height:100px}.mp-header{font-weight:normal!important;font-size:200%!important}tbody,.MainPageBG,#mp-left,#mp-tfa-h2,#mp-tfa,#mp-dyk-h2,#mp-dyk,#mp-right,#mp-itn-h2,mp-itn,#mp-otd-h2,#mp-otd,#mp-tfp,#mp-tfp-h2,#mp-other,#mp-sister,#mp-lang,#jump-to-nav,#mp-strapline,#mp-banner,#mp-upper{background-image:none!important;background-color:inherit!important;color:#000!important;border:none!important}#mp-left,#mp-right{margin-top:80px}#mp-upper img,#mp-tfa img,#mp-left img,#mp-right img{background-color:#f6f6f6!important;color:#000!important;border:none!important;padding:10px!important;margin:10px!important;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;border:1px solid #eaeaea!important}#mp-upper img:hover,#mp-tfa img:hover,#mp-left img:hover,#mp-right img:hover{background-color:#eee!important;border-color:#ddd!important}#mp-tfp-h2,.mw-headline{color:#000!important;background-color:inherit!important;font-weight:bold!important}.mp-left .image{ border:1px solid #f00}.MainPageBG,.MainPageBG tbody,.MainPageBG table,.MainPageBG td,.MainPageBG tr,.MainPageBG th{background-color:#fff!important;color:#000!important;border:none!important}.mergedrow,.floatnone,#searchBody{border:none!important;text-align:left!important}h5#p-search{display:inline}#artikelstadium{position:absolute!important;left:30px!important;top:60px!important;background-color:inherit!important;width:15px;display:inline!important}.portlet h5,.hiddeninputs,.metadata,.centralauth-login-box,.generated-sidebar,.mbox-image,.floatleft,.floatright{display:none!important}#coordinates,#p-gigyaapplet,#p-sharethis,#p-,#p-navigation,#p-interaction,#p-feedback,#p-search,p-tb,#donate,#p-lang,#anontip,#anon-banner,#mp-banner,#filetoc,#No_article_title_matches,#msg-noexactmatch,#mp-strapline,#footer,#siteSub,#p-search,#p-navigation,#p-logo,#p-interaction,#p-tb,#p-lang,#f-list,#f-poweredbyico,#f-copyrightico,#mw_header,#siteNotice,#mr_banner,#mr_banner_topad,#mr_header,#guides,#background_strip,#wikia_header,#widget_sidebar,#monaco_footer,#LEFT_SKYSCRAPER_2_load,#LEFT_SKYSCRAPER_3_load,#LEFT_SKYSCRAPER_1_load,#TOP_RIGHT_BOXAD_load,#page_bar,#google_ads_div_LEFT_SPOTLIGHT_1,#ads{display:none!important}");
  141.         }
  142.         catch(err) {}
  143.  
  144.         // Add font option styles
  145.         if (prefs.headingFont && prefs.bodyFont) {
  146.                 try {
  147.                         GM_addStyle("h1,h2,h3,h4,h5 #mp-tfp-h2,.mp-header,#mp-tfp-h2,.mw-headline{font-family:" + prefs.headingFont + "!important}p,body,#globalWrapper{font-family:" + prefs.bodyFont + "!important}");
  148.                 }
  149.                 catch(err) {}
  150.         }
  151.  
  152.         // Add link colors
  153.         if (prefs.color) {
  154.                 try {
  155.                         GM_addStyle(".toctext,.toclinks,.toclevel-1,a:link,a:visited,a:active{text-decoration:none;color:" + prefs.color + "!important;font-weight:normal}");
  156.                 }
  157.                 catch(err) {}
  158.         }
  159.  
  160.         // Hide all logged in user commands
  161.         if (!prefs.user) {
  162.                 try {
  163.                         GM_addStyle("#login,#pt-login,#edit-ul,#login-ul,#user-ul,.editsection{display:none!important}");
  164.                 }
  165.                 catch(err) {}
  166.         }
  167.  
  168.         // Give the article editing ul an id
  169.         try {
  170.                 var editNav = document.getElementById("ca-nstab-main");
  171.                 editNav.parentNode.setAttribute("id", "edit-ul");
  172.         }
  173.         catch(err) {}
  174.  
  175.         // Front-page specific change for WikipediA only
  176.         if (location.href.match(/http:\/\/?(www\.|)wikipedia\.org\//i)) {
  177.         //if (location.href.match(/http:\/\/?(www\.)?wikipedia\.org\//i)) { //which one is more efficient?
  178.                 var newFrontPage = document.createElement("div");
  179.                 newFrontPage.innerHTML='\
  180.                         <div id="logotype">\
  181.                                 <a href="http://' + prefs.defaultLanguage + '.wikipedia.org/">\
  182.                                         <div id="frontlogo">Wikipedia</div>\
  183.                                 </a>\
  184.                         </div>\
  185.                         <div id="globeLogo">\
  186.                                 <div id="front_search_bar">\
  187.                                         <form id="front-search" action="/w/index.php" method="get">\
  188.                                                 <input name="title" type="hidden" value="Special:Search" />\
  189.                                                 <input name="ns0" type="hidden" value="1" />\
  190.                                                 <input id="frontsearchInput" name="search" type="text" tabindex="1" title="Search Wikipedia [f]" accesskey="f" value="" />\
  191.                                                 <br />\
  192.                                                 <input type="submit" name="submit" value="Search Wikipedia" />\
  193.                                         </form>\
  194.                                         <form id="random-article" action="/wiki/Special:Random">\
  195.                                                 <input type="submit" name="random" value="I\'m Feeling Lucky" />\
  196.                                         </form>\
  197.                                 </div>\
  198.                         </div>';
  199.                 try {
  200.                         newFrontPage.setAttribute('id','NewFront');
  201.                         var oldFrontPage = document.getElementById("bodyContent");
  202.                         oldFrontPage.parentNode.replaceChild(newFrontPage, oldFrontPage);
  203.                 }
  204.                 catch(err) {}
  205.         }
  206.         // Add a new favicon if it is wikipedia
  207.         if (location.href.match(/http:\/\/?(\w*\.|)wikipedia\.org\//i)) {
  208.         //if (location.href.match(/http:\/\/?(\w*\.)?wikipedia\.org\//i)) { //which one is more efficient?
  209.                 var icon = document.createElement("link");
  210.                 icon.setAttribute("type", "image/x-icon");
  211.                 icon.setAttribute("rel", "shortcut icon");
  212.                 icon.setAttribute('href', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAALpJREFUeNrEU1ENhTAMHDjAwiw8C7PwLGABLWhAAlhAwpAwJAyaXJdbs7z3wQdNmjVlbe96o8s5uyfWu4f2fgOHHUQJbx/p04xcpJxHTtxLrSLYcH7ocqAib3IHvDTYfxRxXgcslkIFDVQkTjhnXFeqodTSO+A9KP+J9uCpaRnOKiwEM1DuQPHX0K0oKE+GHY0aiVA1EYgS5+2DUUYnDv8QiK20zLGhfbK19iVujbhoXskH617/Gy8BBgDHv1uI+O2cEwAAAABJRU5ErkJggg%3D%3D');
  213.                 var head = document.getElementsByTagName("head")[0];
  214.                 head.appendChild(icon);
  215.         }
  216.         // Replace the main page header
  217.         var newHeaderContent = document.createElement("h1");
  218.         newHeaderContent.innerHTML="\
  219.                 Wikipedia\
  220.                         ";
  221.         try {
  222.                 newHeaderContent.setAttribute("id","firstHeading")
  223.                 var oldheader = document.getElementById("mp-topbanner");
  224.                 oldheader.parentNode.replaceChild(newHeaderContent,oldheader);
  225.         }
  226.         catch(err) {}
  227.  
  228.         // Create a floating search and language jump nav element
  229.         // Search using whatever search form the page already has
  230.         var searchform = document.getElementById("searchform").getAttribute("action");
  231.                 var searchbar = document.createElement("div");
  232.                 searchbar.innerHTML='\
  233.                                 <form id="search" action="' + searchform + '" method="get">\
  234.                                                 <div id="search_bar">\
  235.                                                         <a href="/">\
  236.                                                                 <img src="http://upload.wikimedia.org/wikipedia/en/b/bd/Bookshelf-40x201_6.png" alt="WikipediA" id="homeLink" />\
  237.                                                         </a>\
  238.                                                         <input name="title" type="hidden" value="Special:Search" />\
  239.                                                         <input name="ns0" type="hidden" value="1" />\
  240.                                                         <input id="searchInput" name="search" type="text" title="Search Wikipedia [f]" accesskey="f" value="" />\
  241.                                                 </div>\
  242.                                 </form>';
  243.                 searchbar.id="floatingsearch";
  244.                 document.getElementById("column-one").appendChild(searchbar);
  245.  
  246.         // Jump to the same article in other languages
  247.         // This mostly works but doesn't jump on change,so I'm not using it yet
  248.         if (prefs.international) {
  249.                 try {
  250.                         var langList = document.getElementById("p-lang").getElementsByTagName("a");
  251.                         if (langList.length > 0) {
  252.                                 var langJump = document.createElement("select");
  253.                                 langJump.id = "langJump";
  254.                                 langJump.name = "langJump";
  255.                                 var langList = document.getElementById("p-lang").getElementsByTagName("a");
  256.                                 var langTitle = document.createElement("option");
  257.                                 // snag 'in another language' in the local translation
  258.                                 langTitle.text = document.getElementById("p-lang").getElementsByTagName('h5')[0].innerHTML;
  259.                                 langJump.add(langTitle,null);
  260.                                 for (var i = 0; i <= langList.length -1; i++) {
  261.                                         var langOpt = document.createElement("option");
  262.                                         langOpt.text = langList[i].innerHTML;
  263.                                         langOpt.value = langList[i];
  264.                                         try {
  265.                                                 langJump.add(langOpt,null);
  266.                                         }
  267.                                 catch(err) {}
  268.                                 }
  269.                                 langJump.addEventListener("change", function() {
  270.                                         window.location.href = this.options[this.selectedIndex].value;
  271.                                 }, false);
  272.                                 try {
  273.                                         document.getElementById("column-one").appendChild(langJump);
  274.                                 }
  275.                                 catch(err) {}
  276.                         }
  277.                 }
  278.                 catch(err) {}
  279.         }
  280.  
  281.         try {
  282.                 // pt-userpage is only there if already logged in
  283.                 var userNav = document.getElementById("pt-userpage");
  284.                 userNav.parentNode.setAttribute("id","user-ul");
  285.                 // when not, use pt-login
  286.                 var userLogin = document.getElementById("pt-login");
  287.                 userLogin.parentNode.parentNode.setAttribute("id","login");
  288.                 userLogin.parentNode.parentNode.setAttribute("class","");
  289.         }
  290.         catch(err) {}
  291.         ////////////////////////////////////////////////////////////////////////////////
  292.         // Auto-updating for Firefox users
  293.         CheckScriptForUpdate = {
  294.                 days: 7, // Days to wait between update checks
  295.                 id: "42312",
  296.                 time: new Date().getTime() | 0,
  297.                 name: "Simplepedia",
  298.                 call: function(response) {
  299.                         GM_xmlhttpRequest({
  300.                                 method: "GET",
  301.                                         url: "https://userscripts.org/scripts/source/" + this.id + ".meta.js",
  302.                                         onload: function(xpr) {CheckScriptForUpdate.compare(xpr, response)}
  303.                         });
  304.                 },
  305.                 compare: function(xpr, response) {
  306.                         this.xversion=/\/\/\s*@version\s+(.*)\s*\n/i.exec(xpr.responseText);
  307.                         this.xname=/\/\/\s*@name\s+(.*)\s*\n/i.exec(xpr.responseText);
  308.                         if (this.xversion && this.xname[1] == this.name) {
  309.                                 this.xversion = this.xversion[1];
  310.                                 this.xname = this.xname[1];
  311.                         } else {
  312.                                 if (xpr.responseText.match("Uh-oh! The page could not be found!") || (this.xname[1] != this.name)) GM_setValue("updated", "off");
  313.                                 return false;
  314.                         }
  315.                         this.xversionParts = this.xversion.split(".");
  316.                         this.versionParts = this.version.split(".");
  317.                         while ((this.xversionParts.length > 0) && (this.versionParts.length > 0))
  318.                         {
  319.                                 if (this.xversionParts[0] < this.versionParts[0])
  320.                                         this.newerVersion = -1;
  321.                                 if (this.xversionParts[0] > this.versionParts[0])
  322.                                         this.newerVersion = 1;
  323.                                 this.xversionParts.shift();
  324.                                 this.versionParts.shift();
  325.                         }
  326.                         if (this.xversionParts.length > 0)
  327.                                 this.newerVersion = -1;
  328.                         if (this.versionParts.length > 0)
  329.                                 this.newerVersion = 1;
  330.                         this.newerVersion = 0;
  331.                         if (this.newerVersion == 1 && confirm("A new version of the " + this.xname + " user script is available. Do you want to update?")) {
  332.                                 GM_setValue("updated", this.time);
  333.                                 GM_openInTab("http://userscripts.org/scripts/source/" + this.id + ".user.js");
  334.                         } else if (this.newerVersion == 1) {
  335.                                 if (confirm("Do you want to turn off auto updating for this script?")) {
  336.                                         GM_setValue("updated", "off");
  337.                                         GM_registerMenuCommand("Auto Update " + this.name, function() {GM_setValue("updated",new Date().getTime() | 0); CheckScriptForUpdate.call("return")});
  338.                                         alert("Automatic updates can be re-enabled for this script from the User Script Commands submenu.");
  339.                                 } else {
  340.                                         GM_setValue("updated", this.time);
  341.                                 }
  342.                         } else {
  343.                                 if (response) alert("No updates available for " + this.name);
  344.                                 GM_setValue("updated", this.time);
  345.                         }
  346.                 },
  347.                 check: function() {
  348.                         if (GM_getValue("updated", 0) == 0) GM_setValue("updated", this.time);
  349.                         if (GM_getValue("updated", 0) != "off" && +this.time > (+GM_getValue("updated", 0) + (1000*60*60*24*this.days))) {
  350.                                 this.call();
  351.                         } else if (GM_getValue("updated", 0) == "off") {
  352.                                 GM_registerMenuCommand("Enable " + this.name + " updates", function() {GM_setValue("updated", new Date().getTime() | 0); CheckScriptForUpdate.call(true)});
  353.                         } else {
  354.                                 GM_registerMenuCommand("Check " + this.name + " for updates", function() {GM_setValue("updated", new Date().getTime() | 0); CheckScriptForUpdate.call(true)});
  355.                         }
  356.                 },
  357.         };
  358.         if (self.location == top.location && GM_xmlhttpRequest) CheckScriptForUpdate.check();
  359. })();
  360. /** Change Log
  361.  * Version 1.1 June 30, 2010
  362.         - Split the version number and compare each individually, instead of
  363.                 stripping dots out of the version in the update check
  364.         - Embed the favicon into the script instead of fetching it from a server
  365.  * Version 1.0 May 6, 2010
  366.         - Automatically detect non-Gecko browsers and act accordingly
  367.         - Attempt GM_getValue() and GM_setValue() before checking for wikis only on Gecko browsers
  368.         - Store prefs in an object
  369.         - Removed extraneous whitespace in CSS
  370.         - Improved readability of auto-update code, sorry sizzlemctwizzle...
  371.         - Squashed a few pref bugs
  372.         - Add new prefs: newColor (new article links), stubColor (stub article links)
  373.  
  374.  * Version .992 September 11, 2009
  375.         - Enclosed all of Simplepedia in an unnamed function
  376.         - Don't execute on Google
  377.         - Don't attempt GM_getValue() or GM_setValue() if the site isn't a wiki
  378.           (for Opera/GreaseKit users who are lazy)
  379.  
  380.  * Version .991 July 17, 2009
  381.         - Added a W favicon for wikipedia only
  382.         - Cleaned preference handling a bit, please reset and reload to use
  383.         - Fixed display of international language selection to use a localized title
  384.         - Darkened the darks a bit
  385.         - Misc. CSS tweaking
  386.         - Updated wikipedia discovery to regex better
  387.  
  388.  * Version .99 July 15, 2009
  389.         - Fixed the alternate language select drop-down and made it an option
  390.  
  391.  * Version .983 July 10, 2009
  392.         - Miscelaneous small CSS fixes adapting to changes made at Wikipedia
  393.         - Simplified front page further
  394.         - Made en.wikipedia closer resemble artile pages
  395.         - Embracing helvetica, possibly renaming to helvetipedia soon
  396.  
  397.  * Version .982 June 22, 2009
  398.         - Tweaked thumbnail picture padding to correct a hover issue (thanks sdfghrr)
  399.         - Tweaked Encyclopedia Dramatica again
  400.  
  401.  * Version .98 June 2, 2009
  402.         - Added a new about:config / cookie option to make customizing link colors more discoverable
  403.  
  404.  * Version .97 June 2, 2009
  405.         - Resolved issues with preference handling in webkit
  406.         - Added disabled preference to dynamically create jump-list of all alternate
  407.           language versions of a given document on wikipedia
  408.  
  409.  * Version .96
  410.         - Generic wiki export has been expanded to specifically support wikia.com,
  411.           while generically supporting any other site with 'wiki' in the CSS @import
  412.  
  413.  * Version .95 May 18, 2009
  414.         - Improved font selection changes and examples
  415.         - Updated namespace
  416.         - Fixed Auto-updating menu selection controls
  417.  
  418.  * Version .94 May 16, 2009
  419.         - Reset font selection to allow greater user control
  420.         - Tweaked JavaScript style, thanks iandalton
  421.         - Updated CSS for multiple fixes
  422.  
  423.  * Version .93 May 14, 2009
  424.         - Added checks to leave user configured items alone, thanks iandalton
  425.         - Updated CSS for multiple fixes
  426.  
  427.  * Version .92 May 10, 2009
  428.         - Complete rewrite
  429.         - Removed document title adjustment
  430.         - Removed specific site support
  431.         - Added generic MediaWiki detection
  432.         - Added proper search form submission detection
  433.         - Began using GreaseMonkey API - Mac users will need secondary scripts now
  434.  
  435.  * Version .9.1 April 30, 2009
  436.         - Fixed front page WikipediA logo (Wikipedia moved it)
  437.         - Dumped Firefox specific auto-updater in favor of pure JS version by Jarett
  438.           http://userscripts.org/scripts/show/20145
  439.         - Fixed http/https mixup when browsing secure sites, Simplepedia will now
  440.           also use https to grab external CSS
  441.         - Updated front page bookshelves to link to random pages because it makes more sense to me
  442.  
  443.  * Version .9 April 29, 2009
  444.         - Added auto-updating via Another Auto Update Script by sizzlemctwizzle
  445.           http://userscripts.org/scripts/show/38017
  446.         - Restored TOC toggle for auscompgeek
  447.  
  448.  * Version .8.1.51 April 13, 2009
  449.         - Added support for http://*.intelink.gov/wiki/*, just in case
  450.  
  451.  * Version .8.1 April 11, 2009
  452.         - Added a simple wikipedia graphic anchor for / by the search bar
  453.         - Swapped the same out on wikipedia.org/
  454.         - Added support for http://wiki.greasespot.net/*
  455.         - Improved user/editor display option
  456.  
  457.  * Version .8 April 5, 2009
  458.         - Added preliminary support for many more wikis http://en.wikipedia.org/wiki/List_of_wikis
  459.           with main page bugs calling them all WikipediA
  460.  
  461.  * Version .7.5 March 30, 2009
  462.         - Reintroduced edit links, page and user login tabs, ++
  463.  
  464.  * Version .7.2.1 March 25, 2009
  465.         - Added helper functions, basic error checking
  466.  
  467.  * Version .7.2 March 18, 2009
  468.         - Added basic support for wikileaks.org
  469.         - Added support for secure WikiMedia sites
  470.  
  471.  * Version .7.1 March 17, 2009
  472.         - Fixed front page form elements in Firefox
  473.         - Added default language links to the front page
  474.  
  475.  * Version .7 March 17, 2009
  476.         - Added 'I'm feeling lucky' and 'Search' buttons to the front portal
  477.         - Reintroduced .noprint content for the main pages
  478.         - Fixed center td border display
  479. */