Jump to content

User:DannyS712 test/view.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by DannyS712 test (talk | contribs) at 02:37, 12 April 2019 (right-navigation). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// VIEW SOURCE
$(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 && location.href.indexOf('&veaction=editsource') === -1) {
  	var to_link = mw.config.get( 'wgPageName' ).replace(/_/g, ' ');
  	editlink = mw.config.get( 'wgArticlePath' ).replace('$1', to_link) + '?action=submit&viewsource=1';
    /**
    //editlink = editbutton.getElementsByTagName('a')[0].href + '&viewsource=1';
    tabs = document.getElementById('p-search');
    na = document.createElement('a');
    na.href = editlink; na.appendChild(document.createTextNode('view source'));
    li = document.createElement('li'); li.id = 'ca-viewsource'; li.appendChild(na);
    tabs.insertBefore(li,editbutton);**/
    mw.util.addPortletLink ( 'right-navigation', editlink, 'View source', 'ca-viewSource', 'View Source', 'p-search');
  }
});