Jump to content

Wikipedia:Tools/View source

From Wikipedia, the free encyclopedia

(function() {

 'use strict';
 if (typeof document === 'undefined' || typeof window === 'undefined' || typeof location === 'undefined') {
   return;
 }
 function run() {
   if (location.href.indexOf('viewsource=1') !== -1) {
     // ... remove edit summary ...
     console.log('View source mode active – edit summary removed.');
     return;
   }
   const editbutton = document.getElementById('ca-edit');
   if (editbutton && location.href.indexOf('action=edit') === -1) {
     // ... add view source tab ...
     console.log('View source tab added.');
   } else {
     console.log('No edit tab found or already in edit mode.');
   }
 }
 if (document.readyState === 'loading') {
   document.addEventListener('DOMContentLoaded', run);
 } else {
   run();
 }

})();