Jump to content

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

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
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('<li>Full protection enabled</li>');
} else if(editLevel === "full" && moveLevel === "te"){
   $('li#pt-userpage').before('<li>Full/TE protection enabled</li>');
} else if(editLevel === "full" && moveLevel === "semi"){
   $('li#pt-userpage').before('<li>Full/Semi protection enabled</li>');
} else if(editLevel === "full" && moveLevel === "none"){
    $('li#pt-userpage').before('<li>Full edit protection enabled</li>');
} else if(editLevel === "te" && moveLevel === "full"){
   $('li#pt-userpage').before('<li>TE/Full protection enabled</li>');
} else if(editLevel === "semi" && moveLevel === "full"){
   $('li#pt-userpage').before('<li>Semi/Full protection enabled</li>');
} else if(editLevel === "te" && moveLevel === "te"){
    $('li#pt-userpage').before('<li>TE protection enabled</li>');
} else if(editLevel === "semi" && moveLevel === "semi"){
    $('li#pt-userpage').before('<li>Semi protection enabled</li>');
} else if(editLevel === "semi" && moveLevel === "none"){
    $('li#pt-userpage').before('<li>Semi edit protection enabled</li>');
} else if(editLevel === "none" && moveLevel === "full"){
    $('li#pt-userpage').before('<li>Full move protection enabled</li>');
} else if(editLevel === "none" && moveLevel === "te"){
   $('li#pt-userpage').before('<li>TE move protection enabled</li>');
} else if(editLevel === "none" && moveLevel === "semi"){
   $('li#pt-userpage').before('<li>Semi move protection enabled</li>');
} else {
    /* Do nothing because there is no protection */
}


/* Protection icons
// Full
$('li#pt-userpage').before('<li id="protected-icon"><a href="/wiki/Wikipedia:Protection_policy#indef" title="This high-risk template is permanently protected from editing."><img alt="Page permanently protected" src="//upload.wikimedia.org/wikipedia/en/thumb/4/48/Padlock-red.svg/20px-Padlock-red.svg.png" srcset="//upload.wikimedia.org/wikipedia/en/thumb/4/48/Padlock-red.svg/30px-Padlock-red.svg.png 1.5x, //upload.wikimedia.org/wikipedia/en/thumb/4/48/Padlock-red.svg/40px-Padlock-red.svg.png 2x" data-file-width="128" data-file-height="128" height="20" width="20"></a></li>');
// TE
$('li#pt-userpage').before('<li id="protected-icon"><a href="/wiki/Wikipedia:Protection_policy#template" title="This high-risk template is permanently protected from editing."><img alt="Permanently protected template" src="//upload.wikimedia.org/wikipedia/commons/thumb/7/70/Padlock-pink.svg/20px-Padlock-pink.svg.png" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/7/70/Padlock-pink.svg/30px-Padlock-pink.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/7/70/Padlock-pink.svg/40px-Padlock-pink.svg.png 2x" data-file-width="128" data-file-height="128" height="20" width="20"></a></li>');

// Semi
$('li#pt-userpage').before('<li id="protected-icon"><a href="/wiki/Wikipedia:Protection_policy#semi" title="This article is semi-protected indefinitely in response to an ongoing high risk of vandalism."><img alt="Page semi-protected" src="//upload.wikimedia.org/wikipedia/commons/thumb/f/fc/Padlock-silver.svg/20px-Padlock-silver.svg.png" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/f/fc/Padlock-silver.svg/30px-Padlock-silver.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/f/fc/Padlock-silver.svg/40px-Padlock-silver.svg.png 2x" data-file-width="128" data-file-height="128" height="20" width="20"></a></li>');

// PC1
<div id="mw-fr-revisiontag" class="flaggedrevs_short plainlinks noprint"><div class="flaggedrevs_short_basic"><img class="flaggedrevs-icon" src="//bits.wikimedia.org/static-1.24wmf11/extensions/FlaggedRevs/frontend/modules/img/doc-magnify.png" alt="Changes must be reviewed before being displayed on this page." title="Changes must be reviewed before being displayed on this page."><b><a href="/wiki/Wikipedia:Pending_changes" title="Wikipedia:Pending changes">Accepted (latest)</a></b><img id="mw-fr-revisiontoggle" class="fr-toggle-arrow" src="//bits.wikimedia.org/static-1.24wmf11/extensions/FlaggedRevs/frontend/modules/img/arrow-down.png" style="display: inline;" alt="show/hide details"></div><a href="/wiki/Wikipedia:Protection_policy#pc1" title="All edits by unregistered and new users are subject to review."><img alt="Page protected with pending changes level 1" src="//upload.wikimedia.org/wikipedia/commons/thumb/2/28/Padlock-silver-light.svg/20px-Padlock-silver-light.svg.png" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/2/28/Padlock-silver-light.svg/30px-Padlock-silver-light.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/2/28/Padlock-silver-light.svg/40px-Padlock-silver-light.svg.png 2x" data-file-width="128" data-file-height="128" height="20" width="20"></a>

// PC2
<div id="mw-fr-revisiontag" class="flaggedrevs_short plainlinks noprint"><div class="flaggedrevs_short_basic"><img class="flaggedrevs-icon" src="//bits.wikimedia.org/static-1.24wmf11/extensions/FlaggedRevs/frontend/modules/img/doc-magnify.png" alt="Changes must be reviewed before being displayed on this page." title="Changes must be reviewed before being displayed on this page."><b><a href="/wiki/Wikipedia:Pending_changes" title="">Accepted (latest)</a></b><img id="mw-fr-revisiontoggle" class="fr-toggle-arrow" src="//bits.wikimedia.org/static-1.24wmf11/extensions/FlaggedRevs/frontend/modules/img/arrow-down.png" style="display: inline;" alt="show/hide details"></div><div id="mw-fr-revisiondetails-wrapper" style="position:relative;"><div id="mw-fr-revisiondetails" class="flaggedrevs_short_details" style="display: none;">This is the <a href="/wiki/Wikipedia:Pending_changes" title="Wikipedia:Pending changes">latest accepted revision</a>, <a class="external text" href="//en.wikipedia.org/w/index.php?title=Special:Log&amp;type=review&amp;page=Conventional_PCI">accepted</a> on <i>June 14, 2014</i>.</div></div></div><a title="All edits by users who are not reviewers or administrators are subject to review." href="/wiki/Wikipedia:Protection_policy#pc2"><img width="20" height="20" data-file-height="128" data-file-width="128" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/a/a9/Padlock-…thumb/a/a9/Padlock-orange.svg/40px-Padlock-orange.svg.png 2x" src="//upload.wikimedia.org/wikipedia/commons/thumb/a/a9/Padlock-orange.svg/20px-Padlock-orange.svg.png" alt="Page protected with pending changes level 2"></img></a>

// Move
$('li#pt-userpage').before('<li id="protected-icon"><a href="/wiki/Wikipedia:Protection_policy#move" title="This article is move-protected."><img alt="Page move-protected" src="//upload.wikimedia.org/wikipedia/en/thumb/5/58/Padlock-olive.svg/20px-Padlock-olive.svg.png" srcset="//upload.wikimedia.org/wikipedia/en/thumb/5/58/Padlock-olive.svg/20px-Padlock-olive.svg.png 1.5x, //upload.wikimedia.org/wikipedia/en/thumb/5/58/Padlock-olive.svg/30px-Padlock-olive.svg.png 2x" data-file-width="128" data-file-height="128" height="15" width="15"></a></li>');

// Create
$('li#pt-userpage').before('<li id="protected-icon"><a href="/wiki/Wikipedia:Protection_policy#create" title="This article is create-protected."><img alt="Page create-protected" src="http://upload.wikimedia.org/wikipedia/en/a/a0/Padlock-skyblue.svg" srcset="//upload.wikimedia.org/wikipedia/en/thumb/a/a0/Padlock-skyblue.svg/20px-Padlock-skyblue.svg.png 1.5x, //upload.wikimedia.org/wikipedia/en/thumb/a/a0/Padlock-skyblue.svg/30px-Padlock-skyblue.svg.png 2x" data-file-width="128" data-file-height="128" height="15" width="15"></a></li>');

*/