MediaWiki:Gadget-find-archived-section.js
Appearance
![]() | This page is loaded as a part of the find-archived-section gadget, used by 5,258 users. |
$.when($.ready).then(function() {
var addsection = document.getElementById('ca-addsection');
var correctNs = mw.config.get('wgNamespaceNumber') % 2 === 1 || mw.config.get('wgNamespaceNumber') === 4;
if (!addsection && mw.user.options.get('skin') !== 'minerva') return;
if (!correctNs && mw.user.options.get('skin') === 'minerva') 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";
}
prefix = encodeURIComponent(prefix);
var search = encodeURIComponent('~"' + hash.replace(/_/g, ' ') + '"');
var searchLink = mw.config.get('wgScript')
+ '?title=Special:Search'
+ '&search=' + search
+ '&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';
$('#mw-content-text').before(div);
});