Difference between revisions of "User:Microchip08/monobook.js"

From Mibbit Wiki
Jump to: navigation, search
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
// http://meta.wikimedia.org/wiki/User:Microchip08/global.js
 
/* UTC clock does not work
 
  Use Mediawiki:monobook.js for .js for all users using the monobook skin
 
  Use Mediawiki:common.js if you really need to
 
*/
 
 
/* Purge caption button */
 
 
addOnloadHook(function () {
 
addOnloadHook(function () {
  var hist; var url;
+
  if (location.href.indexOf('viewsource=1') != -1) {
  if (!(hist = document.getElementById('ca-history') )) return;
+
    sl = document.getElementById('wpSummaryLabel'); sl.parentNode.removeChild(sl);
  if (!(url = hist.getElementsByTagName('a')[0] )) return;
+
    ed = document.getElementById('wpSummary').parentNode; ed.parentNode.removeChild(ed);
  if (!(url = url.href )) return;
+
    return;
  addPortletLink('p-cactions', url.replace(/([?&]action=)history([&#]|$)/, '$1purge$2'),
+
  }
                  'purge', 'ca-purge', 'Purge cache', 'purge');
+
  editbutton = document.getElementById('ca-edit');
 +
  if (editbutton && location.href.indexOf('action=edit')==-1) {
 +
    editlink = editbutton.getElementsByTagName('a')[0].href + '&viewsource=1';
 +
    tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
 +
    na = document.createElement('a');
 +
    na.href = editlink; na.appendChild(document.createTextNode('src'));
 +
    li = document.createElement('li'); li.id = 'ca-viewsource'; li.appendChild(na);
 +
    tabs.insertBefore(li,editbutton);
 +
  }
 
});
 
});

Latest revision as of 21:23, 21 December 2009

addOnloadHook(function () {
  if (location.href.indexOf('viewsource=1') != -1) {
    sl = document.getElementById('wpSummaryLabel'); sl.parentNode.removeChild(sl);
    ed = document.getElementById('wpSummary').parentNode; ed.parentNode.removeChild(ed);
    return;
  }
  editbutton = document.getElementById('ca-edit');
  if (editbutton && location.href.indexOf('action=edit')==-1) {
    editlink = editbutton.getElementsByTagName('a')[0].href + '&viewsource=1';
    tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    na = document.createElement('a');
    na.href = editlink; na.appendChild(document.createTextNode('src'));
    li = document.createElement('li'); li.id = 'ca-viewsource'; li.appendChild(na);
    tabs.insertBefore(li,editbutton);
  }
});