User:Ort43v/common.js
Jump to navigation
Jump to search
Note: You may have to bypass your browser’s cache to see the changes. In addition, after saving a sitewide CSS file such as MediaWiki:Common.css, it will take 5-10 minutes before the changes take effect, even if you clear your cache.
- Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
- Konqueror and Chrome: click Reload or press F5;
- Opera: clear the cache in Tools → Preferences;
- Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.
- This script lacks a documentation subpage. You may create it.
- Useful links: root page • root page’s subpages • links • redirects • your own
This JavaScript is executed for Ort43v on every page load.
/* userTricks - a user script library
* 2012 [[User:Ort43v]]
*/
var userTricks = {
t: null,
testTitle: "",
minHour: 6,
maxHour: 22,
blackout: function(){
document.body.style.backgroundImage = 'none';
document.body.style.backgroundColor = 'black';
},
clear: function(){
document.body.style.display = 'none';
rand = Math.floor(Math.random() * 3);
if (rand > 1) {
userTricks.timer();
}
},
timer: function(){
userTricks.t = setTimeout('userTricks.quiz()',60000);
},
show: function(){
document.body.style.display = 'block';
},
id: function(id){
return document.getElementById(id);
},
quiz: function(){
rand1 = Math.floor(Math.random() * 1000000000);
rand2 = Math.floor(Math.random() * 1000000000);
sum = rand1 + rand2;
ans = prompt(rand1 + '+' + rand2 + ':');
if (isNaN(ans)) {
ans = '1';
}
ans = eval(ans);
if (sum == ans) {
userTricks.show();
}
},
main: function(){
d = new Date();
h = d.getHours();
if (h < userTricks.minHour) {
userTricks.clear();
}
// for testing
if ( mw.config.get( 'wgPageName' ) == userTricks.testTitle ) {
userTricks.clear();
}
}
};
userTricks.main();