Jump to content

Wikipedia:WikiProject User scripts/Scripts/WikiBreak Enforcer

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Mike1024 (talk | contribs) at 23:22, 11 April 2006 (Created page.). 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)

Functionality:

  • Prevents user from logging in before a certain date.
  • If the user logs in, they are automatically logged back out.
  • User can still view/edit as an anon.

Usage:

  • Copy the code below into your monobook.js, adjusting the end date as required. Save the page.
  • Reload a wikipedia page. Mozilla/Safari/Konqueror: hold down Shift while clicking Reload (or press Ctrl-Shift-R), IE: press Ctrl-F5, Opera: press F5.
  • Enjoy your wikibreak!

/* <pre><nowiki> */

function EnforceWikiBreak() {
    var currentdate = new Date();
                                   // YYYY, MM, DD, HH, MM, SS
    var enforced_break_end = new Date(2006, 03, 11, 17, 00, 00);
                     // *** IMPORTANT: Subtract 1 from month, i.e. january = 0 ***

    if (currentdate > enforced_break_end) {
      // alert ("Welcome back from your enforced wikibreak!");
    } else {
      alert ("Enforced wikibreak until " + enforced_break_end.toLocaleString() + " (currently " + currentdate.toLocaleString() + "). Bye!");
      window.location = "http://en.wikipedia.org/w/index.php?title=Special:Userlogout&returnto=Main_page";
    }
}

addOnloadHook(EnforceWikiBreak);

/* </nowiki></pre> */