User:A Quest For Knowledge/monobook.js

addOnloadHook(WikiSanityEnforcer); //******************************************************************************************************************** // Name:         WikiSanityEnforcer // // Summary:      Warns you if an article is being disputed and redirects you to a random article. // // Background:   I got tired of all the pointless edit-warring, POV-pushing, personal attacks, etc. on Wikipedia. //               I know that I could just simply refrain from editing controversial articles, but I lack the //               self-discipline. Some articles are like a train wreck. I know I should look away, but just can't. // //               Therefore, I created this script. Any article marked with a NPOV, OR, BLP, etc. template is //               blocked from view. This allows me to continue to contribute to Wikipedia in non-controversial //               articles and without getting inadvertently dragged into the mud. // // Remarks:      This script has been tested with IE, FireFox and Chrome. // // Customization: 1) The variable promptFirst allows you change whether the user is automatically //                  redirected or is allowed to cancel and view the disputed article.  Simply set promptFirst //                   to true or false depending on your preference. //                2) Individual articles can be excempted from being blocked. To add exceptions to //                  WikiSanityEnforcer, add the article name to the exceptions array in the //                  IsException function. // // History:      2010-02-14   Created //               2010-02-15   Simplified code a bit. //******************************************************************************************************************** function WikiSanityEnforcer {

//use this variable to change whether the user is automatically redirected or is allowed to cancel and view the disputed article. var promptFirst = true; var isDisputed = false; isDisputed = IsDisputed; var isException = false; isException = IsException; if (isDisputed && !isException) {       var redirect = true;

var msg = "This article is disputed. To reduce your WikiStress level, you will be redirected to a random article."; if (promptFirst) {           redirect = confirm(msg); }       else {           alert(msg); }               if (redirect) {           window.location = "http://en.wikipedia.org/wiki/Special:Random"; }   } }//end function

//******************************************************************************************************************** // Name:         IsDisputed // // Summary:      Determines whether an article is the subject of a dispute. // // Remarks:      While researching the various content dispute templates, I noticed that every template used the same //               set of 10 or so images. So rather than parse through the article text to find the template, it //               searches the images to see if there's a match. It's kind of a kludge but it appears to work. // // History:      2010-02-14   Created // //******************************************************************************************************************** function IsDisputed {   var images = new Array(                            "Accessories-text-editor.png",                             "Ambox_content.png",                             "Ambox_question.png",                             "Ambox_scales.svg",                             "Ambox_warning_orange.png",                             "Consensus_icon.png",                             "Edit-clear.png",                             "Question_book-new.png",                            "Text_document_with_red_question_mark.png",                            "Text_document_with_red_question_mark.svg",                            "Unbalanced_scales.svg",                            "Question_book-new.svg",                            "Edit-clear.svg"                           );

var isDisputed = false; for (x=0; x -1) {               isDisputed = true; break; }       }    }    return isDisputed; }//end function

//******************************************************************************************************************** // Name:         IsException // // Summary:      Determines whether an article is excempted from the being blocked. // // Remarks:      Individual articles can be excempted from being blocked. To add exceptions to WikiSanityEnforcer, //               add the article name to the exceptions array below. // // History:      2010-02-14   Created // //******************************************************************************************************************** function IsException {   var exceptions = new Array(                              "REO Speedwagon",                              "ColecoVision",                              ".NET Framework",                              "Intellivision",                              "Atari 7800"                              );

var isException = false; for (x=0; x<exceptions.length; x++) {       if (document.title.substr(0, exceptions[x].length) == exceptions[x]) {           isException = true; break; }   }        return isException; }//end function