User:YLSS/monobook.js

From Wikipedia, the free encyclopedia

If a message on your talk page led you here, please be wary of who left it. Code that you insert on this page could contain malicious content capable of compromising your account. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. If this is a .js page, the code will be executed when previewing the page.
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
//
//--------------- EDIT TOP ------------------
// [[User talk:Alex Smotrov/edittop.js]]
// [[User:Alex Smotrov/edittop.js]]
if (wgAction == 'view' && wgNamespaceNumber >=0)
addOnloadHook(function(){
 var h2s = document.getElementsByTagName('H2');
 var h2 = h2s[0];
 if (!h2) return;
 if (h2.parentNode.id == 'toctitle') h2 = h2s[1];
 if (!h2) return;
 var span = h2.firstChild;
 if (!span || span.className != 'editsection') return;
 var zero = span.cloneNode(true);
 if (document.getElementById('featured-star')) zero.style.marginRight = '25px'
 var parent = document.getElementsByTagName('H1')[0];
 parent.insertBefore(zero, parent.firstChild);
 var a = zero.getElementsByTagName('A')[0];
 a.title = a.title.replace(/:.*$/,': 0');
 a.setAttribute('href', a.href.replace(/&section=1/,'&section=0'));
})
if (wgAction=='edit' && document.URL.indexOf('&section=0') != -1)
addOnloadHook(function(){
  document.getElementById('wpSummary').value = "/* Intro */ ";
})
 
//---------------- EDIT TOOLBAR ---------------------
// Custom buttons above edit window: [[User:MarkS/Extra edit buttons]]
// [[User:MarkS/extraeditbuttons.js]]
XEBOrder='9,V,N,H,O,8,Y1,Y2,K,_MC,_WC,_RM,_R3,_RF,_TL,_MM,_MI,_TC,_LP,_MB,FS';
rmEditButtons=['all'];
myButtons={'_RF':['http://upload.wikimedia.org/wikipedia/commons/9/97/Template_button.png','Reference footer','==References==\n{{reflist|2}}\n','',''],
           '_R3':['http://upload.wikimedia.org/wikipedia/commons/a/a0/Button_references_alt.png','Add named reference tag','<ref name="','"/>','Ref name'],
           '_RM':['http://upload.wikimedia.org/wikipedia/commons/a/a1/Button_template_tl.png','Add ME-cite template',"{{subst:"+"ME-cite|",'|no}}','source'],
           '_TL':['http://upload.wikimedia.org/wikipedia/commons/e/eb/Button_templatelink.png',"Tolkien's legendarium", "[[J. R. R. Tolkien]]'s [[Middle-earth]] [[Tolkien's legendarium|legendarium]]",'',''],
           '_MM':['http://upload.wikimedia.org/wikipedia/commons/d/d0/Button_transwiki.png','Add Merge JRRT template','{{Merge JRRT|',"|{{subst:"+"DATE}}}}",'target'],
           '_MI':['http://upload.wikimedia.org/wikipedia/commons/e/ec/Button_aviso.png','Add ME-importance template',"{{ME-importance|{{subst:"+"DATE}}}}",'',''],
           '_MC':['http://upload.wikimedia.org/wikipedia/commons/1/11/Button_category.png','Middle-earth category', '[[Category:Middle-earth ',']]','category'],
           '_WC':['http://upload.wikimedia.org/wikipedia/commons/b/b6/Button_category_link.png','WikiProject Middle-earth category','[[Category:WikiProject Middle-earth ',']]','category'],
           '_TC':['http://upload.wikimedia.org/wikipedia/commons/8/83/Button_biocitas.png','Template:Tolkienchar','{{Tolkienchar\n|\nimage_character = |\nimage_caption = |\ncharacter_name = ',' |\ncharacter_alias = |\ncharacter_title = |\ncharacter_race = |\ncharacter_culture = |\ncharacter_birth = {{ME-date||}} |\ncharacter_death = {{ME-date||}} |\ncharacter_realm = |\nBook(s) = |\n}}\n','Insert name'],
           '_LP':['http://upload.wikimedia.org/wikipedia/commons/3/30/Button_wn.png','Template:Infobox Me place','{{Infobox Me place |\nplace= ',' |\nimage= |\ncaption= |\nimage_size = px |\nalias = |\ndescription = |\nlocation = |\ntime= {{ME-date||}} |\nbuilt= |\nlord = |\nbooks = |\n}}\n','Insert name'],
           '_MB':['http://upload.wikimedia.org/wikipedia/commons/1/1c/Button_flamme.png','Template:Infobox Me battle', '{|align=right\n|-\n|{{Infobox Me battle |\nbattle= |\nimage= |\ncaption= |\nimage_size= px |\nalias= |\nlocation= |\ndate= {{ME-date||}} |\nresult= |\nbooks= |\nadaptations= |\ncombatant1= |\ncombatant2= |\nparticipants1= †|\nparticipants2= †|\n}}\n{{Campaignbox ','}}\n|}\n','name']};
importScript('User:MarkS/extraeditbuttons.js');
 
 
//------------------- DELTA DIFF ----------------------------
// ENHANCES DIFF view using ajax: [[User:Cacycle/wikEdDiff]]
document.write('<script type="text/javascript" src="'
+ 'http://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEdDiff.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
 
//------------- 6 TABS instead of common 4 ---------------
//page - edit - hist - talk - edit - (+) - hist
// [[Wikipedia:WikiProject User scripts/Scripts/Six tabs]]
importScript('Wikipedia:WikiProject User scripts/Scripts/Six tabs');
 
 
//---------------------- LOGS TAB --------------------------
//Modified from [[Wikipedia:WikiProject User scripts/Scripts/Logs link]]
addOnloadHook(function () {
 if ( wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User_talk" || wgCanonicalNamespace == "Special" ) {
  return;
 } else {
     addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&page=" + wgPageName, "logs", "ca-logs", "Logs for this page");
 }
});
 
//--------------------- 4 USERTABS ----------------------
// Contribs, count, userlogs, userspace - User:Where/usertabs
// [[Wikipedia:WikiProject User scripts/Scripts/User tabs]]
addOnloadHook(function() {
  if (wgTitle.indexOf("/") != -1 || document.title.indexOf("- History -") != -1)  //no subpages or history
     return;
  if (wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User_talk") {
     var username = encodeURIComponent( wgTitle );
     addPortletLink("p-cactions", wgServer + "/wiki/Special:Contributions/" + username, "contribs", "ca-contrib", "User contributions");
     addPortletLink("p-cactions", "http://tools.wikimedia.de/~interiot/cgi-bin/Tool1/wannabe_kate?username=" + username + "&site=en.wikipedia.org", "count", "ca-editcount", "Edit count from Interiot's Tool1");
     addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&user=" + username, "logs", "ca-logs", "Logs by this user");
     addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Prefixindex&from=" + username + "&namespace=2", "userspace", "", "List of pages in this user's userspace");
  }
});
 
//--------------------- SIDEBAR SHORTCUTS ---------------------
// [[Wikipedia:Tools/Navigation shortcuts]] User:Jsimlo/shortcuts.js
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Jsimlo/shortcuts.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
function shortcutsInit ()
{
  shortcutsAddLink ('Me Portal watchlist', 'Special:Recentchangeslinked/Portal:Middle-earth/Pages');
  shortcutsAddLink ('Images watchlist', 'Special:Recentchangeslinked/Wikipedia:WikiProject_Middle-earth/Images?hideminor=0&days=30&limit=250');
  shortcutsAddLink ('Peripherial watchlist', 'Special:Recentchangeslinked/Portal:Middle-earth/Related_pages?hideminor=0&days=7&limit=500');
  shortcutsAddLink ('Sandbox1', 'User:YLSS/Sandbox');
  shortcutsAddLink ('Sandbox2', 'User:YLSS/Sandbox2');
  shortcutsAddLink ('My userspace', 'Special:Prefixindex?from=YLSS&namespace=2');
  shortcutsAddLink ('WT:Me', 'Wikipedia_talk:WikiProject_Middle-earth');
}
 
//--------------------TIME in menu -----------------
// UTC time and date to "personal menu" - [[Wikipedia:WikiProject User scripts/Scripts/Time]]
// by User:Mathwiz2020
insertBeforeNum = 0;
insertBeforeArr = new Array("","pt-userpage","pt-mytalk","pt-preferences","pt-watchlist","pt-mycontris","pt-logout","");
insertBefore = insertBeforeArr[insertBeforeNum];
function makeTime()
{
  var li = document.createElement( 'li' );
  li.id = 'pt-time';
  var mySpan = document.createElement( 'span' );
  mySpan.appendChild( document.createTextNode( 'date and time' ) );
  li.appendChild( mySpan );
  if ( insertBefore )
  {
    var before = document.getElementById( insertBefore );
    before.appendChild( li, before );
  }
  else
  {
    document.getElementById( 'pt-logout' ).parentNode.appendChild( li );
  }
  getTime();
}
if      ( window.addEventListener ) window.addEventListener ( 'load', makeTime, false );
else if ( window.attachEvent      ) window.attachEvent      ( 'onload', makeTime      );
function getTime()
{
    var time    = new Date();
    var date    = time.getUTCDate();
    var months  = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' ');
        month   = months[time.getUTCMonth()];
    var hours   = '0' + time.getUTCHours();
        hours   = hours.substr(hours.length-2, hours.length);
    var minutes = '0' + time.getUTCMinutes();
        minutes = minutes.substr(minutes.length-2, minutes.length);
    var curTime = hours + ":" + minutes + ", " + date + " " + month;
    datePlace   = document.getElementById('pt-time').childNodes[0].childNodes[0];
                  datePlace.replaceData(0, datePlace.length, curTime);
    doTime      = window.setTimeout("getTime()", 1000);
}
 
//------------------ WATCHLIST NOTIFIER ------------------
importScript('User:Ais523/watchlistnotifier.js');
 
 
//---------------- COLORIZE CONTRIBUTIONS ----------------
importScript('User:Ais523/topcontrib.js');
 
 
//--------------------- INTERWIKIS ----------------------
// [[User talk:Alex Smotrov/iwiki.js]]
var iwDisplayMode = 1 // 0 - language name in that language,
// 1 - language name in English, 2 - link in wiki markup with smart tooltip
importScript('User:Alex Smotrov/iwiki.js')
 
 
//--------------------- LOGS TABLE ----------------------
// [[User talk:Alex Smotrov/logpage.js]]
logDateIn = /(\d\d:\d\d), (\d\d?) (\S\S\S)\S* \d\d(\d\d)/
logDateOut = '$1 $2&nbsp;$3&nbsp;$4' //show date as 15:59 27 Sep 07
//logMaxRows = 50 //prevent converting to table by default if > 50 logs
importScript('User:Alex_Smotrov/logpage.js')
 
 
//------------------- QUICK UNWATCH -------------------
// [[User talk:Alex Smotrov/wlunwatch.js]]
if (wgCanonicalSpecialPageName && wgCanonicalSpecialPageName=='Watchlist' && wgAction=='view') 
addOnloadHook(function () {
 var frm = document.getElementsByTagName('form')[0];
 frm.parentNode.insertBefore(document.createTextNode(' | '), frm);
 var lnk = document.createElement('a');
 lnk.appendChild(document.createTextNode('Unwatch…'));
 lnk.href = 'javascript:importScript("User:Alex_Smotrov/wlunwatch.js")';
 frm.parentNode.insertBefore(lnk, frm);
})
 
//------------------- QUICK PREVIEW -----------------------
// [[User talk:Alex Smotrov/qpreview.js]]
//qPreviewAtBottom = true; - uncomment to place at bottom
importScript('User:Alex Smotrov/qpreview.js');
 
 
//----------------- FORCE EDIT SUMMARY ---------------------
importScript('Wikipedia:WikiProject User scripts/Scripts/Force edit summary alternative'); 
 
 
//--------------------    POPUPS    ------------------------
// [[Wikipedia:Tools/Navigation popups]] - User:Lupin/popups.js
importScript('User:Lupin/popups.js');
 
//popupStructure='menus';
//popupShortcutKeys=true;
popupFixDabs=true;
popupRevertSummaryPrompt=true;
popupQueriedRevertSummary='Reverted to revision $1 by $3, using [[WP:POPUPS|popups]]';
popupQueriedRevertToPreviousSummary='Reverted edit $1 by $3, using [[WP:POPUPS|popups]]';
popupFixDabsSummary='Disambiguate [[%s]] to [[%s]], using [[WP:POPUPS|popups]]';
popupHistoryPreviewLimit=12;
removeTitles=false;
popupDelay=1.0;
popupHideDelay=0.3;
popupOnEditSelection=false;
popupWatchDisambiggedPages=false;
 
//