User:BethNaught/exportUserOptions.js

/* global mw */

mw.loader.using(['mediawiki.user'], function {	"use strict";	// List of options which will be not output in restricted mode. Add options containing personal data to this list.	// Testing! Not all options which should be here are.	var blacklist = ["watchlisttoken", "pagetriage-lastuse", "rcfilters-saved-queries", "rcfilters-wl-saved-queries"];	// Alternative whitelist-based system:	/**	var whitelist = ["monobook-responsive", "globaluserpage", "minordefault"];	*/

var config = mw.config.get(['wgNamespaceNumber', 'wgTitle', 'skin']);

function filterBlacklist(key, value) { if (blacklist.includes(key)) { return undefined; } else { return value; }	}

function exportOptionsForm { var bodyContent = (config.skin === "cologneblue" ? "article" : "bodyContent"); document.getElementsByTagName("h1")[0].textContent = "Export user options"; document.title = "Export user options"; document.getElementById(bodyContent).innerHTML = ' ' + '' + ' This page allows convenient export of your user preferences in JSON format. ' +			' You can choose whether to export a restricted set of preferences (unlikely to contain personal data) or all preferences. ' +			'Before sharing the output of this page you should check that no data you do not wish to share is included. ' +           '' + 'Restricted ' + ' ' +			'' + 'All ' + ' ' +			'' + ' ' +			' ' +			' ' +			' ' +			' Output will appear here. ' +       ' ';        document.getElementById("wpExportUserOptions").addEventListener("submit", function(f) {			f.preventDefault;			if (document.getElementById("wpExportUserOptionsRadioAll").checked) {				document.getElementById("wpExportUserOptionsOutput").innerHTML = ' ' + 					JSON.stringify(mw.user.options.values, null, '\t') + ' ';			} else if (document.getElementById("wpExportUserOptionsRadioRestricted").checked) {				document.getElementById("wpExportUserOptionsOutput").innerHTML = ' ' + 					JSON.stringify(mw.user.options.values, filterBlacklist, '\t') + ' ';				// Alternative whitelist-based system:				/**				document.getElementById("wpExportUserOptionsOutput").innerHTML = ' ' + 					JSON.stringify(mw.user.options.values, whitelist, '\t') + ' ';				*/			}		}); }   if (config.wgNamespaceNumber === -1 &&		config.wgTitle.toLowerCase === "exportuseroptions"    ) { exportOptionsForm; }

});