if (app) {
    try {
        Select();
    } catch (e) {

    }
}

function Select() {
    if (ScriptUI.environment.keyboardState.shiftKey) {
        var idslct = charIDToTypeID("slct");
        var desc8 = new ActionDescriptor();
        var idnull = charIDToTypeID("null");
        var ref6 = new ActionReference();
        var idLyr = charIDToTypeID("Lyr ");
        ref6.putName(idLyr, "Over Saturation Check");
        desc8.putReference(idnull, ref6);
        var idMkVs = charIDToTypeID("MkVs");
        desc8.putBoolean(idMkVs, false);
        executeAction(idslct, desc8, DialogModes.NO);
        var idDlt = charIDToTypeID("Dlt ");
        var desc9 = new ActionDescriptor();
        var idnull = charIDToTypeID("null");
        var ref7 = new ActionReference();
        var idLyr = charIDToTypeID("Lyr ");
        var idOrdn = charIDToTypeID("Ordn");
        var idTrgt = charIDToTypeID("Trgt");
        ref7.putEnumerated(idLyr, idOrdn, idTrgt);
        desc9.putReference(idnull, ref7);
        executeAction(idDlt, desc9, DialogModes.NO);
    } else {
        var idMk = charIDToTypeID("Mk  ");
        var desc2 = new ActionDescriptor();
        var idnull = charIDToTypeID("null");
        var ref1 = new ActionReference();
        var idAdjL = charIDToTypeID("AdjL");
        ref1.putClass(idAdjL);
        desc2.putReference(idnull, ref1);
        var idUsng = charIDToTypeID("Usng");
        var desc3 = new ActionDescriptor();
        var idType = charIDToTypeID("Type");
        var idvibrance = stringIDToTypeID("vibrance");
        desc3.putClass(idType, idvibrance);
        var idAdjL = charIDToTypeID("AdjL");
        desc2.putObject(idUsng, idAdjL, desc3);
        executeAction(idMk, desc2, DialogModes.NO);
        var idslct = charIDToTypeID("slct");
        var desc4 = new ActionDescriptor();
        var idnull = charIDToTypeID("null");
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID("Chnl");
        var idChnl = charIDToTypeID("Chnl");
        var idRGB = charIDToTypeID("RGB ");
        ref2.putEnumerated(idChnl, idChnl, idRGB);
        desc4.putReference(idnull, ref2);
        var idMkVs = charIDToTypeID("MkVs");
        desc4.putBoolean(idMkVs, false);
        executeAction(idslct, desc4, DialogModes.NO);

        function OVersert() {
            function step1(enabled, withDialog) {
                if (enabled != undefined && !enabled) {
                    return;
                }
                var dialogMode = withDialog ? DialogModes.ALL : DialogModes.NO;
                var desc1 = new ActionDescriptor();
                var ref1 = new ActionReference();
                ref1.putEnumerated(PSClass.AdjustmentLayer, PSType.Ordinal, PSEnum.Target);
                desc1.putReference(PSString.Null, ref1);
                var desc2 = new ActionDescriptor();
                desc2.putInteger(sTID("vibrance"), -100);
                desc2.putInteger(PSKey.Start, 100);
                desc1.putObject(PSKey.To, sTID("vibrance"), desc2);
                executeAction(PSEvent.Set, desc1, dialogMode);
            }
            step1();
        }
        cTID = function(s) {
            return app.charIDToTypeID(s);
        };
        sTID = function(s) {
            return app.stringIDToTypeID(s);
        };
        OVersert.loadSymbols = function() {
            var dbgLevel = $.level;
            $.level = 0;
            try {
                PSConstants;
                return;
            } catch (e) {

            } finally {
                $.level = dbgLevel;
            }
            var needDefs = true;
            $.level = 0;
            try {
                PSClass;
                needDefs = false;
            } catch (e) {

            } finally {
                $.level = dbgLevel;
            }
            if (needDefs) {
                PSClass = function() {

                };
                PSEnum = function() {

                };
                PSEvent = function() {

                };
                PSForm = function() {

                };
                PSKey = function() {

                };
                PSType = function() {

                };
                PSUnit = function() {

                };
                PSString = function() {

                };
            }
            PSClass.AdjustmentLayer = cTID("AdjL");
            PSEnum.Target = cTID("Trgt");
            PSEvent.Set = cTID("setd");
            PSKey.Start = cTID("Strt");
            PSKey.To = cTID("T   ");
            PSString.Null = sTID("null");
            PSType.Ordinal = cTID("Ordn");
        };
        OVersert.loadSymbols();
        OVersert.main = function() {
            OVersert();
        };
        OVersert.main();
        var idsetd = charIDToTypeID("setd");
        var desc5 = new ActionDescriptor();
        var idnull = charIDToTypeID("null");
        var ref3 = new ActionReference();
        var idLyr = charIDToTypeID("Lyr ");
        var idOrdn = charIDToTypeID("Ordn");
        var idTrgt = charIDToTypeID("Trgt");
        ref3.putEnumerated(idLyr, idOrdn, idTrgt);
        desc5.putReference(idnull, ref3);
        var idT = charIDToTypeID("T   ");
        var desc6 = new ActionDescriptor();
        var idNm = charIDToTypeID("Nm  ");
        desc6.putString(idNm, "Over Saturation Check");
        var idLyr = charIDToTypeID("Lyr ");
        desc5.putObject(idT, idLyr, desc6);
        executeAction(idsetd, desc5, DialogModes.NO);
        var idslct = charIDToTypeID("slct");
        var desc2 = new ActionDescriptor();
        var idnull = charIDToTypeID("null");
        var ref1 = new ActionReference();
        var idChnl = charIDToTypeID("Chnl");
        var idChnl = charIDToTypeID("Chnl");
        var idMsk = charIDToTypeID("Msk ");
        ref1.putEnumerated(idChnl, idChnl, idMsk);
        desc2.putReference(idnull, ref1);
        var idMkVs = charIDToTypeID("MkVs");
        desc2.putBoolean(idMkVs, false);
        executeAction(idslct, desc2, DialogModes.NO);
        var idDlt = charIDToTypeID("Dlt ");
        var desc3 = new ActionDescriptor();
        var idnull = charIDToTypeID("null");
        var ref2 = new ActionReference();
        var idChnl = charIDToTypeID("Chnl");
        var idOrdn = charIDToTypeID("Ordn");
        var idTrgt = charIDToTypeID("Trgt");
        ref2.putEnumerated(idChnl, idOrdn, idTrgt);
        desc3.putReference(idnull, ref2);
        executeAction(idDlt, desc3, DialogModes.NO);
    }
}