User:Suffusion of Yellow/vpt-mockup.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Suffusion of Yellow/vpt-mockup. |
// Proof concept only. Not intended for actual use!
// <nowiki>
$(function() {
'use strict';
var info = {
"user-agent": {
dangerous: true,
get: function() {
return window.navigator.userAgent;
}
},
"screen-resolution": {
dangerous: true,
get: function() {
return window.screen.width + "x" + window.screen.height;
}
},
"skin": {
get: function() {
return mw.user.options.values.skin;
}
},
"relevant-pages": {
get: function() {
var skin = mw.user.options.values.skin;
var prefix = "User:" + mw.config.get('wgUserName') + "/";
return '[[' + prefix + 'common.js|commons.js]], ' +
'[[' + prefix + 'common.css|common.css]], ' +
'[[' + prefix + skin + '.js|' + skin + '.js]], ' +
'[[' + prefix + skin + '.css|' + skin + '.css]], ' +
'[[:meta:' + prefix + 'global.js|global.js]], ' +
'[[:meta:' + prefix + 'global.css|global.css]]';
}
},
"gadgets": {
get: function() {
var gadgets = [];
for(var opt in mw.user.options.values) {
if (opt.indexOf("gadget-") === 0)
gadgets.push(opt.slice(7));
}
return gadgets.join(", ");
}
}
};
if (mw.config.get('wgPageName') === "Special:BlankPage/TechInfo") {
var $content = $('#mw-content-text').html("");
var basic = "";
var dangerous = "";
for(var name in info)
if (info.hasOwnProperty(name)) {
var result;
try {
result = info[name].get();
} catch(e) {
result = "unknown";
}
var line = "* " + name + ": " + result + "\n";
if (info[name].dangerous)
dangerous += line;
else
basic += line;
}
$content.append("<h2>Usually safe to share<h/2>");
var $basic = $("<textarea></textarea>", {
rows: 20,
readonly: true
});
$basic.val(basic).appendTo($content);
$content.append("<h2>Possibly unsafe to share</h2>");
$content.append("<div>This information may be <a href='https://panopticlick.eff.org'>used to track you</a> on the web.</div>");
var $dangerous = $("<textarea></textarea>", {
rows: 5,
readonly: true
});
$dangerous.val(dangerous).appendTo($content);
}
});
//</nowiki>