Jump to content

MediaWiki:Gadget-find-archived-section.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by SD0001 (talk | contribs) at 11:25, 9 June 2019 (new script). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
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.
$.when(mw.loader.using('mediawiki.util'), $.ready).then(function() {
	if (document.getElementById('ca-addsection') === null) {
		return;
	}

	var hash = decodeURIComponent(window.location.hash.slice(1));
	if (hash === '' || document.getElementById(hash.replace(/ /g, '_')) !== null) {
		return;
	}

	var prefix = mw.config.get('wgPageName').replace(/_/g, ' ');
	if (prefix === "Wikipedia:Administrators' noticeboard/Incidents") {
		prefix = "Wikipedia:Administrators' noticeboard/IncidentArchive";
	} else if (prefix === "Wikipedia:Administrators' noticeboard/Edit warring") {
		prefix = "Wikipedia:Administrators' noticeboard/3RRArchive";
	} else if (prefix === "Wikipedia:Administrators' noticeboard") {
		prefix = "Wikipedia:Administrators' noticeboard/Archive";
	}

	var searchLink = mw.util.getUrl('Special:Search', {
		'search': '"' + hash.replace(/_/g, ' ') + '"',
		'prefix': prefix
	});

	var div = document.createElement('div');
	div.innerHTML = 'Looks like the discussion "' + hash.replace(/_/g, ' ') + 
	'" has been archived. <a href="' + searchLink + '">Click to search in archives</a>.';
	div.style.fontSize = '90%';
	div.style.paddingLeft = '20px';

	$('#contentSub').after(div);

});