Jump to content

User:Kangaroopower/rawtab.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Kangaroopower (talk | contribs) at 06:24, 8 February 2014. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
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'),
		tab = '<li id="ca-raw"><a href="/w/index.php?title='+ mw.config.get('wgPageName') +'&action=raw&ctype=text/javascript">Raw</a></li>';
 
	if ((page.endsWith('.js') || page.endsWith('.css')) && mw.config.get('wgNamespaceNumber') !== -1) { 
		if (mw.config.get ( 'skin' ) === 'vector') {	
			$('#ca-talk').after(tab);
		} else {
			$('#ca-move').before();
		}
	}
});