Jump to content

User:Slaporte/FeedbackTab.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.
/**
 * Add Feedback v5 Tab
 * @source: http://en.wikipedia.org/wiki/User:Slaporte/FeedbackTab.js
 * @author: Stephen LaPorte
 */

$.getJSON(
	mw.util.wikiScript( 'api' ), {
		'format': 'json',
		'action': 'query',
		'list': 'articlefeedbackv5-view-ratings',
		'afpageid': mw.config.get('wgArticleId')
	}, function ( data ) {
		if(data['query']['articlefeedbackv5-view-ratings']['rollup']['found']['count'] > 0) {
			function createTab() {
				mw.util.addPortletLink( 'p-views', 'http://en.wikipedia.org/wiki/Special:ArticleFeedbackv5/' + mw.config.get('wgTitle'), 'Feedback');
		}
		addOnloadHook( createTab );
	}
});