Jump to content

User:Awesome Aasim/editrequest.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.
var AER = {};
AER.AERSettings = {};
AER.requestPages = ["Category:Wikipedia_semi-protected_edit_requests", "Category:Wikipedia_extended-confirmed-protected_edit_requests", "Category:Wikipedia_template-protected_edit_requests", "Category:Wikipedia_fully-protected_edit_requests", "Category:Wikipedia_interface-protected_edit_requests"];
if (mw.config.get("wgPageName").toLowerCase() == "Special:BlankPage/EditProtected".toLowerCase()) {
	if (mw.config.get("wgUserGroups").includes("autoconfirmed") || mw.config.get("wgUserGroups").includes("confirmed") || mw.config.get("wgUserGroups").includes("extendedconfirmed") || mw.config.get("wgUserGroups").includes("templateeditor") || mw.config.get("wgUserGroups").includes("sysop") || mw.config.get("wgUserGroups").includes("interface-admin")) {
		AER.defaultPrefs = "";
		$.get(mw.config.get("wgScriptPath") + "/api.php", {
			"action": "parse",
			"format": "json",
			"prop": "wikitext",
			'page': "User:Awesome Aasim/editrequest.js/defaultpreferences.json"
		}).done(function (d) {
			AER.defaultPrefs = JSON.parse(d.parse.wikitext["*"]);
			$.get(mw.config.get("wgScriptPath") + "/api.php", {
				"action": "parse",
				"format": "json",
				"prop": "wikitext",
				"page": "User:" + mw.config.get("wgUserName") + "/AERpreferences.json"
			}).done(function (preferences) {
				if (preferences.error) {
					if (preferences.error.code == "missingtitle") {
						mw.notify("Loading preferences for the Answer Edit Requests tool...");
						$(document).ready(function () {
							$.get(mw.config.get('wgScriptPath') + '/api.php', {
								"action": "query",
								"format": "json",
								"meta": "tokens",
								"type": "csrf"
							}).done(function (x) {
								if (x.error) {
									throw x.error;
								} else {
									$.get(mw.config.get('wgScriptPath') + '/api.php', {
										'action': 'parse',
										'page': "User:Awesome Aasim/editrequest.js/defaultpreferences.json",
										'prop': 'wikitext',
										'format': 'json'
									}).done(function (z) {
										AER.AERSettings = JSON.parse(z.parse.wikitext["*"]);
										$.post(mw.config.get("wgScriptPath") + '/api.php', {
											"action": "edit",
											"format": "json",
											"title": "User:" + mw.config.get("wgUserName") + "/AERpreferences.json",
											"text": z.parse.wikitext["*"],
											"summary": "Loading preferences for [[User:Awesome Aasim/editrequest|AER]] tool",
											"token": x.query.tokens.csrftoken
										}).done(function (y) {
											if (y.error) {
												$.get(mw.config.get('wgScriptPath') + '/api.php', {
													"action": 'parse',
													"prop": 'text',
													"pst": 'true',  // PST = pre-save transform; this makes substitution work properly
													"text": y.error.info,
													"format": "json"
												}).done(function (r) {
													console.log(r);
													if (r.error) {
														console.error(r.error);
													} else {
														$(".firstHeading").text("Permission error");
														$("#section_0").text("Permission error");
														$("title").text("Permission error - Wikipedia");
														$("#mw-content-text").html(r.parse.text["*"]).append('<p id="mw-returnto">Return to <a href="/wiki/Main_Page">Main Page</a>.</p>');
													}
												}).fail(function (_r) {

												});
											} else {
											if (AER.AERSettings.sidebarlink) {
												mw.util.addPortletLink("p-interaction", "/wiki/Special:BlankPage/EditProtected", "Answer edit requests");
											}
												mw.loader.load("//en.wikipedia.org/w/index.php?title=User:Awesome_Aasim/editrequest.js/stable.js&action=raw&ctype=text/javascript");
											}
										}).fail(function (y) {
											alert("Network settings may have changed.  Please reload the page.");
										});
									}).fail(function (z) {
										alert("Network settings may have changed.  Please reload the page.");
									})
								}
							}).fail(function (x) {
								alert("Network settings may have changed.  Please reload the page.");
							})

						})
					} else {
						$(document).ready(function () {
							$("#mw-content-text").text("Error has occurred.  Please reload.");
						})
					}
				} else {
					$.get(mw.config.get('wgScriptPath') + '/api.php', {
						"action": "query",
						"format": "json",
						"meta": "tokens",
						"type": "csrf"
					}).done(function (x) {
						if (x.error) {
							throw x.error;
						} else {
							$.get(mw.config.get('wgScriptPath') + '/api.php', {
								'action': 'parse',
								'page': "User:" + mw.config.get("wgUserName") + "/AERpreferences.json",
								'prop': 'wikitext',
								'format': 'json'
							}).done(function (z) {
								AER.AERSettings = JSON.parse(z.parse.wikitext["*"]);
								for (var i in AER.defaultPrefs) {
									if (!(i in AER.AERSettings)) {
										AER.AERSettings[i] = AER.defaultPrefs[i];
									}
								}
								$.post(mw.config.get("wgScriptPath") + '/api.php', {
									"action": "edit",
									"format": "json",
									"title": "User:" + mw.config.get("wgUserName") + "/AERpreferences.json",
									"text": JSON.stringify(AER.AERSettings),
									"summary": "Loading preferences for [[User:Awesome Aasim/editrequest|AER]] tool",
									"token": x.query.tokens.csrftoken
								}).done(function (y) {
									if (y.error) {
										$.get(mw.config.get('wgScriptPath') + '/api.php', {
											"action": 'parse',
											"prop": 'text',
											"pst": 'true',  // PST = pre-save transform; this makes substitution work properly
											"text": y.error.info,
											"format": "json"
										}).done(function (r) {
											console.log(r);
											if (r.error) {
												console.error(r.error);
											} else {
												$(".firstHeading").text("Permission error");
												$("#section_0").text("Permission error");
												$("title").text("Permission error - Wikipedia");
												$("#mw-content-text").html(r.parse.text["*"]).append('<p id="mw-returnto">Return to <a href="/wiki/Main_Page">Main Page</a>.</p>');
											}
										}).fail(function (_r) {

										});
									} else {
										if (AER.AERSettings.sidebarlink) {
											mw.util.addPortletLink("p-interaction", "/wiki/Special:BlankPage/EditProtected", "Answer edit requests");
										}
										if (AER.AERSettings.beta == true) {
											mw.notify($("<span>You are running the Answer Edit Requests beta version of the tool. This may not be 100% stable.  Please especially review every edit you make with the tool.  Report any problems on the <a href=\"/wiki/User_talk:Awesome_Aasim/editrequest\">AER talk page.</a></span>"));
											mw.loader.load("//en.wikipedia.org/w/index.php?title=User:Awesome_Aasim/editrequest.js/beta.js&action=raw&ctype=text/javascript");
										} else {
											mw.loader.load("//en.wikipedia.org/w/index.php?title=User:Awesome_Aasim/editrequest.js/stable.js&action=raw&ctype=text/javascript");
										}
									}
								}).fail(function (y) {
									alert("Network settings may have changed.  Please reload the page.");
								});
							}).fail(function (z) {
								alert("Network settings may have changed.  Please reload the page.");
							})
						}
					}).fail(function (x) {
						alert("Network settings may have changed.  Please reload the page.");
					})
				}
			}).fail(function (preferences) {
				alert("Network settings may have changed.  Please reload the page.");
			})
		}).fail(function (d) {

		});
	} else {
		$(document).ready(function () {
			$(".firstHeading").text("Permission error");
			$("#section_0").text("Permission error");
			$("title").text("Permission error - Wikipedia");
			$('#mw-content-text').html('<p>Access to this tool is restricted to <a href="/wiki/Wikipedia:Autoconfirmed">autoconfirmed</a> and <a href="/wiki/Wikipedia:Confirmed">confirmed</a> users.</p><p id="mw-returnto">Return to <a href="/wiki/Main_Page">Main Page</a>.</p>');
		})
	}
} else if (mw.config.get("wgPageName") == "Category:Wikipedia_edit_requests" || AER.requestPages.includes(mw.config.get("wgPageName"))) {
	if (mw.config.get("wgUserGroups").includes("autoconfirmed") || mw.config.get("wgUserGroups").includes("confirmed") || mw.config.get("wgUserGroups").includes("extendedconfirmed") || mw.config.get("wgUserGroups").includes("templateeditor") || mw.config.get("wgUserGroups").includes("sysop") || mw.config.get("wgUserGroups").includes("interface-admin")) {
		AER.defaultPrefs = "";
		$.get(mw.config.get("wgScriptPath") + "/api.php", {
			"action": "parse",
			"format": "json",
			"prop": "wikitext",
			'page': "User:Awesome Aasim/editrequest.js/defaultpreferences.json"
		}).done(function (d) {
			AER.defaultPrefs = JSON.parse(d.parse.wikitext["*"]);
			$.get(mw.config.get("wgScriptPath") + "/api.php", {
				"action": "parse",
				"format": "json",
				"prop": "wikitext",
				"page": "User:" + mw.config.get("wgUserName") + "/AERpreferences.json"
			}).done(function (preferences) {
				if (preferences.error) {
					if (preferences.error.code == "missingtitle") {
						mw.notify("Loading preferences for the Answer Edit Requests tool...");
						$(document).ready(function () {
							$.get(mw.config.get('wgScriptPath') + '/api.php', {
								"action": "query",
								"format": "json",
								"meta": "tokens",
								"type": "csrf"
							}).done(function (x) {
								if (x.error) {
									throw x.error;
								} else {
									$.get(mw.config.get('wgScriptPath') + '/api.php', {
										'action': 'parse',
										'page': "User:Awesome Aasim/editrequest.js/defaultpreferences.json",
										'prop': 'wikitext',
										'format': 'json'
									}).done(function (z) {
										AER.AERSettings = JSON.parse(z.parse.wikitext["*"]);
										$.post(mw.config.get("wgScriptPath") + '/api.php', {
											"action": "edit",
											"format": "json",
											"title": "User:" + mw.config.get("wgUserName") + "/AERpreferences.json",
											"text": z.parse.wikitext["*"],
											"summary": "Loading preferences for [[User:Awesome Aasim/editrequest|AER]] tool",
											"token": x.query.tokens.csrftoken
										}).done(function (y) {
											if (y.error) {
												$.get(mw.config.get('wgScriptPath') + '/api.php', {
													"action": 'parse',
													"prop": 'text',
													"pst": 'true',  // PST = pre-save transform; this makes substitution work properly
													"text": y.error.info,
													"format": "json"
												}).done(function (r) {
													console.log(r);
													if (r.error) {
														console.error(r.error);
													} else {
														$(".firstHeading").text("Permission error");
														$("#section_0").text("Permission error");
														$("title").text("Permission error - Wikipedia");
														$("#mw-content-text").html(r.parse.text["*"]).append('<p id="mw-returnto">Return to <a href="/wiki/Main_Page">Main Page</a>.</p>');
													}
												}).fail(function (_r) {

												});
											} else {
												if (AER.AERSettings.sidebarlink) {
													mw.util.addPortletLink("p-interaction", "/wiki/Special:BlankPage/EditProtected", "Answer edit requests");
												}
											}
										}).fail(function (y) {
											alert("Network settings may have changed.  Please reload the page.");
										});
									}).fail(function (z) {
										alert("Network settings may have changed.  Please reload the page.");
									});
								}
							}).fail(function (x) {
								alert("Network settings may have changed.  Please reload the page.");
							})
						})
					} else {
						$(document).ready(function () {
							$("#mw-content-text").text("Error has occurred.  Please reload.");
						})
					}
				} else {
					$.get(mw.config.get('wgScriptPath') + '/api.php', {
						"action": "query",
						"format": "json",
						"meta": "tokens",
						"type": "csrf"
					}).done(function (x) {
						if (x.error) {
							throw x.error;
						} else {
							$.get(mw.config.get('wgScriptPath') + '/api.php', {
								'action': 'parse',
								'page': "User:" + mw.config.get("wgUserName") + "/AERpreferences.json",
								'prop': 'wikitext',
								'format': 'json'
							}).done(function (z) {
								AER.AERSettings = JSON.parse(z.parse.wikitext["*"]);
								for (var i in AER.defaultPrefs) {
									if (!(i in AER.AERSettings)) {
										AER.AERSettings[i] = AER.defaultPrefs[i];
									}
								}
								$.post(mw.config.get("wgScriptPath") + '/api.php', {
									"action": "edit",
									"format": "json",
									"title": "User:" + mw.config.get("wgUserName") + "/AERpreferences.json",
									"text": JSON.stringify(AER.AERSettings),
									"summary": "Loading preferences for [[User:Awesome Aasim/editrequest|AER]] tool",
									"token": x.query.tokens.csrftoken
								}).done(function (y) {
									if (y.error) {
										
									} else {
										if (AER.AERSettings.sidebarlink) {
											mw.util.addPortletLink("p-interaction", "/wiki/Special:BlankPage/EditProtected", "Answer edit requests");
										}
									}
								}).fail(function (y) {
									
								});
							}).fail(function (z) {
								
							})
						}
					}).fail(function (x) {
						
					})
				}
			}).fail(function (preferences) {
				
			})
		}).fail(function (d) {

		});
		$(document).ready(function () {
			$("#siteNotice").append('<p>Consider using <a href="/wiki/Special:BlankPage/EditProtected">the edit protected tool</a> to review edit requests!</p>');
		});
	}
} else if (mw.config.get("wgPageName").toLowerCase() == "Special:BlankPage/EditProtectedPrefs".toLowerCase()) {
	if (mw.config.get("wgUserGroups").includes("autoconfirmed") || mw.config.get("wgUserGroups").includes("confirmed") || mw.config.get("wgUserGroups").includes("extendedconfirmed") || mw.config.get("wgUserGroups").includes("templateeditor") || mw.config.get("wgUserGroups").includes("sysop") || mw.config.get("wgUserGroups").includes("interface-admin")) {
		AER.defaultPrefs = "";
		$.get(mw.config.get("wgScriptPath") + "/api.php", {
			"action": "parse",
			"format": "json",
			"prop": "wikitext",
			'page': "User:Awesome Aasim/editrequest.js/defaultpreferences.json"
		}).done(function (d) {
			AER.defaultPrefs = JSON.parse(d.parse.wikitext["*"]);
			$.get(mw.config.get("wgScriptPath") + "/api.php", {
				"action": "parse",
				"format": "json",
				"prop": "wikitext",
				"page": "User:" + mw.config.get("wgUserName") + "/AERpreferences.json"
			}).done(function (preferences) {
				if (preferences.error) {
					if (preferences.error.code == "missingtitle") {
						mw.notify("Loading preferences for the Answer Edit Requests tool...");
						$(document).ready(function () {
							$.get(mw.config.get('wgScriptPath') + '/api.php', {
								"action": "query",
								"format": "json",
								"meta": "tokens",
								"type": "csrf"
							}).done(function (x) {
								if (x.error) {
									throw x.error;
								} else {
									$.get(mw.config.get('wgScriptPath') + '/api.php', {
										'action': 'parse',
										'page': "User:Awesome Aasim/editrequest.js/defaultpreferences.json",
										'prop': 'wikitext',
										'format': 'json'
									}).done(function (z) {
										AER.AERSettings = JSON.parse(z.parse.wikitext["*"]);
										$.post(mw.config.get("wgScriptPath") + '/api.php', {
											"action": "edit",
											"format": "json",
											"title": "User:" + mw.config.get("wgUserName") + "/AERpreferences.json",
											"text": z.parse.wikitext["*"],
											"summary": "Loading preferences for [[User:Awesome Aasim/editrequest|AER]] tool",
											"token": x.query.tokens.csrftoken
										}).done(function (y) {
											if (y.error) {
												$.get(mw.config.get('wgScriptPath') + '/api.php', {
													"action": 'parse',
													"prop": 'text',
													"pst": 'true',  // PST = pre-save transform; this makes substitution work properly
													"text": y.error.info,
													"format": "json"
												}).done(function (r) {
													console.log(r);
													if (r.error) {
														console.error(r.error);
													} else {
														$(".firstHeading").text("Permission error");
														$("#section_0").text("Permission error");
														$("title").text("Permission error - Wikipedia");
														$("#mw-content-text").html(r.parse.text["*"]).append('<p id="mw-returnto">Return to <a href="/wiki/Main_Page">Main Page</a>.</p>');
													}
												}).fail(function (_r) {

												});
											} else {
												if (AER.AERSettings.sidebarlink) {
													mw.util.addPortletLink("p-interaction", "/wiki/Special:BlankPage/EditProtected", "Answer edit requests");
												}
												mw.loader.load("//en.wikipedia.org/w/index.php?title=User:Awesome_Aasim/editrequest.js/stable.js&action=raw&ctype=text/javascript");
											}
										}).fail(function (y) {
											alert("Network settings may have changed.  Please reload the page.");
										});
									}).fail(function (z) {
										alert("Network settings may have changed.  Please reload the page.");
									});
								}
							}).fail(function (x) {
								alert("Network settings may have changed.  Please reload the page.");
							})
						})
					} else {
						$(document).ready(function () {
							$("#mw-content-text").text("Error has occurred.  Please reload.");
						})
					}
				} else {
					$.get(mw.config.get('wgScriptPath') + '/api.php', {
						"action": "query",
						"format": "json",
						"meta": "tokens",
						"type": "csrf"
					}).done(function (x) {
						if (x.error) {
							throw x.error;
						} else {
							$.get(mw.config.get('wgScriptPath') + '/api.php', {
								'action': 'parse',
								'page': "User:" + mw.config.get("wgUserName") + "/AERpreferences.json",
								'prop': 'wikitext',
								'format': 'json'
							}).done(function (z) {
								AER.AERSettings = JSON.parse(z.parse.wikitext["*"]);
								for (var i in AER.defaultPrefs) {
									if (!(i in AER.AERSettings)) {
										AER.AERSettings[i] = AER.defaultPrefs[i];
									}
								}
								$.post(mw.config.get("wgScriptPath") + '/api.php', {
									"action": "edit",
									"format": "json",
									"title": "User:" + mw.config.get("wgUserName") + "/AERpreferences.json",
									"text": JSON.stringify(AER.AERSettings),
									"summary": "Loading preferences for [[User:Awesome Aasim/editrequest|AER]] tool",
									"token": x.query.tokens.csrftoken
								}).done(function (y) {
									if (y.error) {
										$.get(mw.config.get('wgScriptPath') + '/api.php', {
											"action": 'parse',
											"prop": 'text',
											"pst": 'true',  // PST = pre-save transform; this makes substitution work properly
											"text": y.error.info,
											"format": "json"
										}).done(function (r) {
											console.log(r);
											if (r.error) {
												console.error(r.error);
											} else {
												$(".firstHeading").text("Permission error");
												$("#section_0").text("Permission error");
												$("title").text("Permission error - Wikipedia");
												$("#mw-content-text").html(r.parse.text["*"]).append('<p id="mw-returnto">Return to <a href="/wiki/Main_Page">Main Page</a>.</p>');
											}
										}).fail(function (_r) {

										});
									} else {
										if (AER.AERSettings.sidebarlink) {
											mw.util.addPortletLink("p-interaction", "/wiki/Special:BlankPage/EditProtected", "Answer edit requests");
										}
										if (AER.AERSettings.beta == true) {
											mw.notify($("<span>You are running the Answer Edit Requests beta version of the tool. This may not be 100% stable.  Please especially review every edit you make with the tool.  Report any problems on the <a href=\"/wiki/User_talk:Awesome_Aasim/editrequest\">AER talk page.</a></span>"));
											mw.loader.load("//en.wikipedia.org/w/index.php?title=User:Awesome_Aasim/editrequest.js/beta.js&action=raw&ctype=text/javascript");
										} else {
											mw.loader.load("//en.wikipedia.org/w/index.php?title=User:Awesome_Aasim/editrequest.js/stable.js&action=raw&ctype=text/javascript");
										}
									}
								}).fail(function (y) {
									alert("Network settings may have changed.  Please reload the page.");
								});
							}).fail(function (z) {
								alert("Network settings may have changed.  Please reload the page.");
							})
						}
					}).fail(function (x) {
						alert("Network settings may have changed.  Please reload the page.");
					})
				}
			}).fail(function (preferences) {
				alert("Network settings may have changed.  Please reload the page.");
			})
		}).fail(function (d) {

		});

	} else {
		$(document).ready(function () {
			$(".firstHeading").text("Permission error");
			$("#section_0").text("Permission error");
			$("title").text("Permission error - Wikipedia");
			$('#mw-content-text').html('<p>Access to this tool is restricted to <a href="/wiki/Wikipedia:Autoconfirmed">autoconfirmed</a> and <a href="/wiki/Wikipedia:Confirmed">confirmed</a> users.</p><p id="mw-returnto">Return to <a href="/wiki/Main_Page">Main Page</a>.</p>');
		})
	}
} else {
	if (mw.config.get("wgUserGroups").includes("autoconfirmed") || mw.config.get("wgUserGroups").includes("confirmed") || mw.config.get("wgUserGroups").includes("extendedconfirmed") || mw.config.get("wgUserGroups").includes("templateeditor") || mw.config.get("wgUserGroups").includes("sysop") || mw.config.get("wgUserGroups").includes("interface-admin")) {
		AER.defaultPrefs = "";
		$.get(mw.config.get("wgScriptPath") + "/api.php", {
			"action": "parse",
			"format": "json",
			"prop": "wikitext",
			'page': "User:Awesome Aasim/editrequest.js/defaultpreferences.json"
		}).done(function (d) {
			AER.defaultPrefs = JSON.parse(d.parse.wikitext["*"]);
			$.get(mw.config.get("wgScriptPath") + "/api.php", {
				"action": "parse",
				"format": "json",
				"prop": "wikitext",
				"page": "User:" + mw.config.get("wgUserName") + "/AERpreferences.json"
			}).done(function (preferences) {
				if (preferences.error) {
					if (preferences.error.code == "missingtitle") {
						mw.notify("Loading preferences for the Answer Edit Requests tool...");
						$(document).ready(function () {
							$.get(mw.config.get('wgScriptPath') + '/api.php', {
								"action": "query",
								"format": "json",
								"meta": "tokens",
								"type": "csrf"
							}).done(function (x) {
								if (x.error) {
									throw x.error;
								} else {
									$.get(mw.config.get('wgScriptPath') + '/api.php', {
										'action': 'parse',
										'page': "User:Awesome Aasim/editrequest.js/defaultpreferences.json",
										'prop': 'wikitext',
										'format': 'json'
									}).done(function (z) {
										AER.AERSettings = JSON.parse(z.parse.wikitext["*"]);
										$.post(mw.config.get("wgScriptPath") + '/api.php', {
											"action": "edit",
											"format": "json",
											"title": "User:" + mw.config.get("wgUserName") + "/AERpreferences.json",
											"text": z.parse.wikitext["*"],
											"summary": "Loading preferences for [[User:Awesome Aasim/editrequest|AER]] tool",
											"token": x.query.tokens.csrftoken
										}).done(function (y) {
											if (y.error) {
												$.get(mw.config.get('wgScriptPath') + '/api.php', {
													"action": 'parse',
													"prop": 'text',
													"pst": 'true',  // PST = pre-save transform; this makes substitution work properly
													"text": y.error.info,
													"format": "json"
												}).done(function (r) {
													console.log(r);
													if (r.error) {
														console.error(r.error);
													} else {
														$(".firstHeading").text("Permission error");
														$("#section_0").text("Permission error");
														$("title").text("Permission error - Wikipedia");
														$("#mw-content-text").html(r.parse.text["*"]).append('<p id="mw-returnto">Return to <a href="/wiki/Main_Page">Main Page</a>.</p>');
													}
												}).fail(function (_r) {

												});
											} else {
												if (AER.AERSettings.sidebarlink) {
													mw.util.addPortletLink("p-interaction", "/wiki/Special:BlankPage/EditProtected", "Answer edit requests");
												}
											}
										}).fail(function (y) {
											alert("Network settings may have changed.  Please reload the page.");
										});
									}).fail(function (z) {
										alert("Network settings may have changed.  Please reload the page.");
									});
								}
							}).fail(function (x) {
								alert("Network settings may have changed.  Please reload the page.");
							})
						})
					} else {
						$(document).ready(function () {
							$("#mw-content-text").text("Error has occurred.  Please reload.");
						})
					}
				} else {
					$.get(mw.config.get('wgScriptPath') + '/api.php', {
						"action": "query",
						"format": "json",
						"meta": "tokens",
						"type": "csrf"
					}).done(function (x) {
						if (x.error) {
							throw x.error;
						} else {
							$.get(mw.config.get('wgScriptPath') + '/api.php', {
								'action': 'parse',
								'page': "User:" + mw.config.get("wgUserName") + "/AERpreferences.json",
								'prop': 'wikitext',
								'format': 'json'
							}).done(function (z) {
								AER.AERSettings = JSON.parse(z.parse.wikitext["*"]);
								for (var i in AER.defaultPrefs) {
									if (!(i in AER.AERSettings)) {
										AER.AERSettings[i] = AER.defaultPrefs[i];
									}
								}
								$.post(mw.config.get("wgScriptPath") + '/api.php', {
									"action": "edit",
									"format": "json",
									"title": "User:" + mw.config.get("wgUserName") + "/AERpreferences.json",
									"text": JSON.stringify(AER.AERSettings),
									"summary": "Loading preferences for [[User:Awesome Aasim/editrequest|AER]] tool",
									"token": x.query.tokens.csrftoken
								}).done(function (y) {
									if (y.error) {
										
									} else {
										if (AER.AERSettings.sidebarlink) {
											mw.util.addPortletLink("p-interaction", "/wiki/Special:BlankPage/EditProtected", "Answer edit requests");
										}
									}
								}).fail(function (y) {
									
								});
							}).fail(function (z) {
								
							})
						}
					}).fail(function (x) {
						
					})
				}
			}).fail(function (preferences) {
				
			})
		}).fail(function (d) {

		});
	}
}
//</nowiki>