Jump to content

User:NguoiDungKhongDinhDanh/ShowRevisionID.js

From Wikipedia, the free encyclopedia
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.
/* Show Revision ID */

// Shows the revision id on history and Special pages
// Documentation at [[User:BrandonXLF/ShowRevisionID]]
// Originally by [[User:BrandonXLF]].

$(function() {
	mw.hook('wikipage.content').add(function() {
		if (mw.config.get('wgAction') !== 'history' && mw.config.get('wgNamespaceNumber') !== -1) {
			return;
		}
		
		const items = $('li[data-mw-revid]').not('.with-revid');
		
		for (let i = 0; i < items.length; i++) {
			const separator = document.createElement('span');
			separator.textContent = ' | ';
			separator.style.userSelect = 'none';
			
			items[i].classList.add('with-revid');
			items[i].getElementsByClassName('mw-changeslist-date')[0].append(
				separator,
				document.createTextNode(items[i].getAttribute('data-mw-revid'))
			);
		}
	});
});