mic_none

User:Kangaroopower/rawtab.js Source: en.wikipedia.org/wiki/User:Kangaroopower/rawtab.js

// Adds a portlet that says raw to js and css pages which links to the raw text version of the page
/* Put: 
// [[User:Kangaroopower/scripts/rawtab.js]] 
importScript('User:Kangaroopower/scripts/rawtab.js');
in your skins's js page to use
*/

String.prototype.endsWith = function (txt) {
	if (txt.length > this.length || txt.length <= 0) return false; 
	return this.substring(this.length - txt.length, this.length) === txt;
};
 
$(document).ready(function() {
	var page = mw.config.get('wgPageName'),
		end;

	if ((page.endsWith('.js') || page.endsWith('.css')) && mw.config.get('wgNamespaceNumber') !== -1) { 
		end = page.endsWith('.js') ? 'javascript' : 'css';
		mw.util.addPortletLink( 'p-namespaces', '/w/index.php?title='+ page +'&action=raw&ctype=text/'+ end, 'Raw');
	}
});