User:Technical 13/Scripts/Gadget-pageProtectionLevels.js

var editLevel = mw.config.get('wgRestrictionEdit');

if(editLevel !== "" || typeof(editLevel) !== 'undefined' || editLevel !== null){

if ($.inArray('sysop', editLevel) >= 0){

editLevel = "full";

}

else if ($.inArray('autoconfirmed', editLevel) >= 0){

editLevel = "semi";

}

else if ($.inArray('templateeditor', editLevel) >= 0){

editLevel = "te";

} else {

editLevel = "none";

}

} else {

editLevel = "none";

}

var moveLevel = mw.config.get('wgRestrictionMove');

if(moveLevel !== "" || typeof(moveLevel) !== 'undefined' || moveLevel !== null){

if ($.inArray('sysop', moveLevel) >= 0){

moveLevel = "full";

}

else if ($.inArray('templateeditor', moveLevel) >= 0){

moveLevel = "te";

}

else if ($.inArray('autoconfirmed', moveLevel) >= 0){

moveLevel = "semi";

} else {

moveLevel = "none";

}

} else {

moveLevel = "none";

}

if(editLevel === "full" && moveLevel === "full"){

$('li#pt-userpage').before('

  • Full protection enabled
  • ');

    } else if(editLevel === "full" && moveLevel === "te"){

    $('li#pt-userpage').before('

  • Full/TE protection enabled
  • ');

    } else if(editLevel === "full" && moveLevel === "semi"){

    $('li#pt-userpage').before('

  • Full/Semi protection enabled
  • ');

    } else if(editLevel === "full" && moveLevel === "none"){

    $('li#pt-userpage').before('

  • Full edit protection enabled
  • ');

    } else if(editLevel === "te" && moveLevel === "full"){

    $('li#pt-userpage').before('

  • TE/Full protection enabled
  • ');

    } else if(editLevel === "semi" && moveLevel === "full"){

    $('li#pt-userpage').before('

  • Semi/Full protection enabled
  • ');

    } else if(editLevel === "te" && moveLevel === "te"){

    $('li#pt-userpage').before('

  • TE protection enabled
  • ');

    } else if(editLevel === "semi" && moveLevel === "semi"){

    $('li#pt-userpage').before('

  • Semi protection enabled
  • ');

    } else if(editLevel === "semi" && moveLevel === "none"){

    $('li#pt-userpage').before('

  • Semi edit protection enabled
  • ');

    } else if(editLevel === "none" && moveLevel === "full"){

    $('li#pt-userpage').before('

  • Full move protection enabled
  • ');

    } else if(editLevel === "none" && moveLevel === "te"){

    $('li#pt-userpage').before('

  • TE move protection enabled
  • ');

    } else if(editLevel === "none" && moveLevel === "semi"){

    $('li#pt-userpage').before('

  • Semi move protection enabled
  • ');

    } else {

    /* Do nothing because there is no protection */

    }

    /* Protection icons

    // Full

    $('li#pt-userpage').before('

  • Page permanently protected
  • ');

    // TE

    $('li#pt-userpage').before('

  • Permanently protected template
  • ');

    // Semi

    $('li#pt-userpage').before('

  • Page semi-protected
  • ');

    // PC1