Jump to content

User:Equazcion/ScriptInstaller.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Equazcion (talk | contribs) at 16:17, 1 October 2013 (Created page with ' $('.installer').each(function(){ var path = $('.installer').attr('href'); $('.installer').html('<a class="installerLink">install</a>'); path = path.replace('...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
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.
$('.installer').each(function(){
	var path = $('.installer').attr('href');
	$('.installer').html('<a class="installerLink">install</a>');
	path = path.replace('#','');

	$(this).click(function(){
		var requestData = {
			action:"edit", 
			title: "User:"+mw.config.get("wgUserName")+"/common.js", 
			appendtext: "\n\nimportScript('" + path + "'); //Added by Script Installer", 
			summary: "Script Installer", 
			token:mw.user.tokens.get("editToken")
		};
		
		$.post(mw.config.get("wgScriptPath")+"/api.php", requestData, function(responseData){
		    //Whatever you want to do *after* the edit is posted goes here. For example:
		    alert("posted successfully!");
		});
		
	});

});