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 20:41, 1 January 2012. 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.
function endsWith(text) {
    for(var i = 0; i < text.length; i++) {
	if(this.charAt((this.length - 1) - i) != text.charAt((text.length - 1) - i)) {return false;}
    }
    return true;
}
String.prototype.endsWith = endsWith;
function addrawtab () {
   if (wgPageName.endsWith('.js') == true) { 
	if ( mw.config.get ( 'skin' ) == 'vector' ) {	

		$('#ca-talk').after('<li id="ca-raw"><span><a href="//en.wikipedia.org/w/index.php?title='+ wgPageName +'&action=raw&ctype=text/javascript">Raw</a></span></li>');
	} else {
			
		$('#ca-move').before('<li id="ca-raw"><a href="//en.wikipedia.org/w/index.php?title='+ wgPageName +'&action=raw&ctype=text/javascript">Raw</a></li>');
	}
   }
addOnloadHook('addrawtab');