Jump to content

User:No se/common.js

From translatewiki.net

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
mw.loader.load('//commons.wikimedia.org/wiki/MediaWiki:Gadget-HotCat.js?action=raw&ctype=text/javascript');
mw.loader.load('/wiki/User:Jon_Harald_Søby/terminology.js?action=raw&ctype=text/javascript'); // [[User:Jon Harald Søby/terminology.js]]
mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Jon_Harald_Søby/diffedit.js&action=raw&ctype=text/javascript');
const SpecialURL = mw.util.getUrl('Special:ComparePages');
if (mw.config.get('wgArticleId') !== 0) {const CompareURL = mw.config.get('wgPageName').replace(/&|%26/g,'%26').replace(/\+/g,'%2b').replace(/_/g,'+');
	let ToolsList = document.querySelector('#p-tb ul');
	let ListItem = Object.assign(document.createElement('li'), {id:'t-compare', className:'mw-list-item mw-list-item-js'});
	ToolsList.appendChild(ListItem);
	let ComparePage1 = document.createElement('a');
	ComparePage1.href = SpecialURL + '?page1=' + CompareURL;
	ComparePage1.title = 'View the comparison between this page with another or a revision';
	ComparePage1.style = 'display:inline-block';
	ComparePage1.textContent = 'Compare this page';
	ListItem.append(ComparePage1);
	let ComparePage2 = ComparePage1.cloneNode();
	ComparePage2.href = SpecialURL + '?page2=' + CompareURL;
	ComparePage2.title = 'View the comparison between another page or revision with this one';
	ComparePage2.textContent = 'alt';
	ListItem.append(document.createTextNode(' ('), ComparePage2, document.createTextNode(')'))}
//testing down here
let otitle = document.querySelector("#mw-diff-otitle1>strong");
let ntitle = document.querySelector("#mw-diff-ntitle1>strong");
if (otitle && ntitle) {a = function(a) {return a.querySelector('strong>a')};
	if (a(otitle) && a(ntitle)) {match = function (match) {return match.href.match(/&oldid=(\d+)/)};
		if (match(a(otitle)) && match(a(ntitle))) {console.log(match(a(otitle))[1], match(a(otitle))[1])}
		else {console.log('No se encontró ninguna URL o el oldid en ella')} }
	else {console.log('No se encontró el elemento <a>')} }