Jump to content

User:SD0001/UnassessedArticleLinks.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.
/**
 * Simple script to manipulate links to the talk pages at unassessed article category pages, such as 
 * [[:Category:Unassessed biography articles]] or [[:Category:Unknown-importance cricket articles]] 
 * so that they
 * - point straight to the articles
 * - get opened in a new tab by default
 * - redirect is not followed
 * - Evad37's Rater is opened automatically on the article
 */

$.when(mw.loader.using('mediawiki.util'), $.ready).then(function() {
	if (mw.config.get('wgPageName').indexOf('Category:Unassessed') === 0 || 
	mw.config.get('wgPageName').indexOf('Category:Unknown-importance') === 0) {
		$('.mw-category ul li a').each(function(i,e) {
		    e.href = e.href.replace('/wiki/Talk:', '/wiki/').replace(/$/, '?redirect=no&autostartrater=y');
		    e.target = '_blank';
		});
	}
	setTimeout(function() {
		if (mw.util.getParamValue('autostartrater')) {
			$('#ca-rater').click();
		}
	}, 1000);
});