User:Metaknowledge/vector.js

From Wiktionary, the free dictionary
Jump to navigation Jump to search

Note – after saving, you may have to bypass your browser’s cache to see the changes.

  • Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
  • Konqueror and Chrome: click Reload or press F5;
  • Opera: clear the cache in Tools → Preferences;
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

This JavaScript is executed for Metaknowledge on every page load, when User:Metaknowledge is using the Vector skin.


// <nowiki>
//Note: This is all a pile of stuff stolen (and sometimes slightly modified) from users like Ruakh, Liliana-60, Hippietrail, Yair rand, and Surjection to whom I say - THANKS! 
mw.loader.load("https://en.wiktionary.org/w/index.php?title=User:Conrad.Irwin/edittools.js&action=raw&ctype=text/javascript");
addOnloadHook
( function ()
  { $('span.mw-rollback-link a').each
    ( function ()
      { if(this.href.indexOf('&action=rollback&') == -1)
          return;
        if(this.href.indexOf('summary=') > -1)
          return;
        this.href +=
          '&summary=' +
          encodeURIComponent
          ( 'Reverted edits by [[Special:Contributions/$2|$2]]. ' +
            'If you think this rollback is in error, ' +
            'please leave a message on [[User talk:Metaknowledge|my talkpage]].'
          );
      }
    );
  }
);

/*addOnloadHook
( function ()
  { if(mediaWiki.config.get('wgPageName') == 'Special:WhatLinksHere/-im')
      $('ul#mw-whatlinkshere-list a').each
      ( function ()
        { if(this.href.indexOf('/wiki/') > -1)
            this.href += '?action=edit';
        }
      );
    else if(document.location.href.indexOf('action=edit') > -1)
    { var wpTextbox1 = document.getElementById('wpTextbox1');
      if(wpTextbox1.value.indexOf('\n{{head|tpi|verb') > -1)
      { wpTextbox1.value =
          wpTextbox1.value.replace(/\n{{head[|]tpi[|]verb}}/g, '\n#* {{tpi-verb[|]t}}');
        document.getElementById('wpSummary').value =
          'Tok Pisin converting {{head|tpi|verb}} to {{tpi-verb}}';
        document.getElementById('wpSave').click();
      }
    }
  }
);*/
importScript('User:Yair rand/orangelinks2.js');

// make <s> and <strike> and redlinks in headers apparent in TOC:
addOnloadHook
(
   function ()
   {
     if(! document.getElementById)
       return;
     var toc = document.getElementById('toc');
     if(! toc)
       return;
     if(! toc.getElementsByTagName)
       return;
     toc = toc.getElementsByTagName('a');
     for(var i = 0; i < toc.length; ++i)
     {
       var link = toc[i];
       var target = link.hash.substr(1);
       if(! target || ! target.length)
         continue;
       target = document.getElementById(target);
       if(! target)
         continue;
       if(target.getElementsByTagName('a').length > 0)
         if(target.getElementsByTagName('a')[0].className == 'new')
           link.className = 'new';
       var firstChild = target.childNodes[0];
       if(firstChild.nodeType != Node.ELEMENT_NODE)
         continue;
       if(firstChild.tagName == 'S' || firstChild.tagName == 'STRIKE')
       {
         var s = document.createElement('s');
         while(link.childNodes.length > 0)
           s.appendChild(link.childNodes[0]);
         link.appendChild(s);
       }
     }
   }
);
 


 
// make "diff" links on watchlist match corresponding links in revision history:
addOnloadHook
(
  function()
  {
    if(mw.config.get('wgPageName') != 'Special:Watchlist')
      return;
    var specials = document.getElementsByClassName('special');
    for(var i = 0; i < specials.length; ++i)
    {
      var lis = specials[i].getElementsByTagName('li');
      for(var j = 0; j < lis.length; ++j)
      {
        var link = lis[j].getElementsByTagName('a')[0];
        if(! link) // shouldn't happen
          continue;
        if(link.innerHTML != 'diff') // new pages, log entries, etc.
          continue;
        link.href = link.href.replace(/&(amp;)?curid=\d+/, '');
      }
    }
  }
);

window.GPE = window.GPE || {};
window.GPE.initialDeleteReason = '[[Wiktionary:Sysop deleted|--explanation of deletion--]]';

importScript("User:Yair rand/FindTrans.js");
importScript("User:Kephir/gadgets/xte.js");

mw.loader.load('//en.wikipedia.org/w/index.php?title=User:קיפודנחש/viewstats.js&action=raw&ctype=text/javascript');

$(function() {
	$("#firstHeading").prop("contenteditable", "true");
	$('#firstHeading').keypress(function (e) {
		var key = e.which;
		if(key == 13) {
			window.location = "https://en.wiktionary.org/w/index.php?search=" + $('#firstHeading').text() + "&title=Special%3ASearch&go=Go";
			return false;
		}
	});
});
//</nowiki>

importScript("User:Dixtosa/AjaxEdit.js");

$('.mw-logline-move a[href*="wpReason=revert"]').each(function() {
		if (this.href.indexOf('&autosubmitmove=1') < 0) 
			this.href += '&wpLeaveRedirect=0&autosubmitmove=1';
	});
	if (mw.config.get("wgPageName").startsWith("Special:MovePage") && new URL(window.location.href).searchParams.get("autosubmitmove") == '1') {
		$('button[name="wpMove"]').click();
	}